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)
committerPhil Hagelberg <phil@hagelb.org>
Sun, 1 Mar 2020 02:53:49 +0000 (18:53 -0800)
lib/pleroma/plugs/static_fe_plug.ex

index b3fb3c582037c1cc7d393edf299dc44a964c1bf3..a8b22c243f7a979a26b82aeb337203afdb9c93f4 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