Skip to content

Commit

Permalink
Make sure the query string is also added to return_to in 404
Browse files Browse the repository at this point in the history
  • Loading branch information
ukutaht committed Dec 17, 2024
1 parent b9a113b commit 6bf8c83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plausible_web/templates/error/404_error.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% end %>
<div class="mt-4 flex">
<%= if !@conn.assigns[:current_user] do %>
<.button_link href={Routes.auth_path(@conn, :login_form, return_to: @conn.request_path <> "?" <> @conn.query_string)} class="mr-4">Log in</.button_link>
<.button_link href={Routes.auth_path(@conn, :login_form, return_to: url_path(@conn))} class="mr-4">Log in</.button_link>
<% end %>
<.button_link theme="bright" href={PlausibleWeb.LayoutView.home_dest(@conn)}>
Go to homepage
Expand Down
3 changes: 3 additions & 0 deletions lib/plausible_web/views/error_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,7 @@ defmodule PlausibleWeb.ErrorView do
rescue
_ -> %{status: 500, message: "Server error"}
end

defp url_path(%Plug.Conn{request_path: path, query_string: ""}), do: path
defp url_path(%Plug.Conn{request_path: path, query_string: query}), do: path <> "?" <> query
end

0 comments on commit 6bf8c83

Please sign in to comment.