aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-07-07 00:04:24 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-07-07 00:04:24 +0000
commit2a323d37971d364fefd46e840424c631cc4a7d2b (patch)
tree86a5cc0ad9afb6158d18ef6c4200a7c6e147b1da /lib
parent69f0b286f7b3e0518ac7ae54dfb06539dc179698 (diff)
parent158c26d7ddb3c77dc99a6298114929faf6a2915a (diff)
downloadpleroma-2a323d37971d364fefd46e840424c631cc4a7d2b.tar.gz
Merge branch '1507-static-fe-prioritize-json' into 'develop'
StaticFE: Prioritize json in requests. Closes #1507 See merge request pleroma/pleroma!2695
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/plugs/static_fe_plug.ex9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/pleroma/plugs/static_fe_plug.ex b/lib/pleroma/plugs/static_fe_plug.ex
index 156e6788e..143665c71 100644
--- a/lib/pleroma/plugs/static_fe_plug.ex
+++ b/lib/pleroma/plugs/static_fe_plug.ex
@@ -9,7 +9,7 @@ defmodule Pleroma.Plugs.StaticFEPlug do
def init(options), do: options
def call(conn, _) do
- if enabled?() and accepts_html?(conn) do
+ if enabled?() and requires_html?(conn) do
conn
|> StaticFEController.call(:show)
|> halt()
@@ -20,10 +20,7 @@ defmodule Pleroma.Plugs.StaticFEPlug do
defp enabled?, do: Pleroma.Config.get([:static_fe, :enabled], false)
- defp accepts_html?(conn) do
- case get_req_header(conn, "accept") do
- [accept | _] -> String.contains?(accept, "text/html")
- _ -> false
- end
+ defp requires_html?(conn) do
+ Phoenix.Controller.get_format(conn) == "html"
end
end