Fix static FE plug to handle missing Accept header.
authorPhil Hagelberg <phil@hagelb.org>
Sun, 1 Mar 2020 02:53:49 +0000 (18:53 -0800)
committerrinpatch <rinpatch@sdf.org>
Sun, 15 Mar 2020 14:00:06 +0000 (17:00 +0300)
lib/pleroma/plugs/static_fe_plug.ex

index deebe48791ceb8cc9185a3c5d9cba020a1f6c2d0..156e6788e0980fbf658ccf9fcd72a975d65ab2c6 100644 (file)
@@ -21,6 +21,9 @@ defmodule Pleroma.Plugs.StaticFEPlug do
   defp enabled?, do: Pleroma.Config.get([:static_fe, :enabled], false)
 
   defp accepts_html?(conn) do
-    conn |> get_req_header("accept") |> List.first() |> String.contains?("text/html")
+    case get_req_header(conn, "accept") do
+      [accept | _] -> String.contains?(accept, "text/html")
+      _ -> false
+    end
   end
 end