Merge pull request 'Fix LiveDashboard redirect not working when user added a path segment' (#7830) from live-dashboard-fix-redirect into develop
Reviewed-on: https://git.pleroma.social/pleroma/pleroma/pulls/7830
This commit is contained in:
commit
eabfb2bd47
4 changed files with 19 additions and 3 deletions
1
changelog.d/live-dashboard-redirect.fix
Normal file
1
changelog.d/live-dashboard-redirect.fix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Fix /phoenix/live_dashboard redirect not working when user added a path segment
|
||||
|
|
@ -29,9 +29,18 @@ defmodule Pleroma.Web.Fallback.RedirectController do
|
|||
)
|
||||
end
|
||||
|
||||
def live_dashboard(conn, _params) do
|
||||
def live_dashboard(conn, %{"path" => path}) do
|
||||
query_params = conn.query_string
|
||||
|
||||
redirect_path =
|
||||
if query_params == "" do
|
||||
"/pleroma/live_dashboard/#{path}"
|
||||
else
|
||||
"/pleroma/live_dashboard/#{path}?#{query_params}"
|
||||
end
|
||||
|
||||
conn
|
||||
|> redirect(to: "/pleroma/live_dashboard")
|
||||
|> redirect(to: redirect_path)
|
||||
end
|
||||
|
||||
def redirector(conn, _params, code \\ 200) do
|
||||
|
|
|
|||
|
|
@ -1093,7 +1093,7 @@ defmodule Pleroma.Web.Router do
|
|||
get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
|
||||
match(:*, "/api/pleroma/*path", LegacyPleromaApiRerouterPlug, [])
|
||||
get("/api/*path", RedirectController, :api_not_implemented)
|
||||
get("/phoenix/live_dashboard", RedirectController, :live_dashboard)
|
||||
get("/phoenix/live_dashboard/*path", RedirectController, :live_dashboard)
|
||||
get("/*path", RedirectController, :redirector_with_preload)
|
||||
|
||||
options("/*path", RedirectController, :empty)
|
||||
|
|
|
|||
|
|
@ -79,6 +79,12 @@ defmodule Pleroma.Web.FallbackTest do
|
|||
|
||||
test "GET /phoenix/live_dashboard -> /pleroma/live_dashboard", %{conn: conn} do
|
||||
assert redirected_to(get(conn, "/phoenix/live_dashboard")) =~ "/pleroma/live_dashboard"
|
||||
assert redirected_to(get(conn, "/phoenix/live_dashboard/")) =~ "/pleroma/live_dashboard/"
|
||||
end
|
||||
|
||||
test "GET /phoenix/live_dashboard/* -> /pleroma/live_dashboard/*", %{conn: conn} do
|
||||
assert redirected_to(get(conn, "/phoenix/live_dashboard/ecto_stats?nav=diagnose")) =~
|
||||
"/pleroma/live_dashboard/ecto_stats?nav=diagnose"
|
||||
end
|
||||
|
||||
test "OPTIONS /*path", %{conn: conn} do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue