File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -9,20 +9,23 @@ defmodule AlgoraWeb.Util do
99 def build_safe_redirect ( url ) do
1010 app_host = AlgoraWeb.Endpoint . host ( )
1111
12- case URI . parse ( url ) do
12+ uri = URI . parse ( url )
13+ query = if uri . query , do: "?#{ uri . query } " , else: ""
14+
15+ case uri do
1316 % URI { host: nil , path: nil } ->
14- [ to: ~p" /" ]
17+ [ to: ~p" /#{ query } " ]
1518
1619 % URI { host: host , path: path } when is_nil ( host ) or host == app_host ->
17- [ to: path ]
20+ [ to: " #{ path } #{ query } " ]
1821
1922 % URI { host: host } ->
2023 case host |> String . split ( "." ) |> Enum . take ( - 2 ) |> Enum . join ( "." ) do
2124 "algora.io" -> [ external: url ]
2225 "algora.tv" -> [ external: url ]
2326 "stripe.com" -> [ external: url ]
2427 "github.com" -> [ external: url ]
25- _ -> [ to: ~p" /" ]
28+ _ -> [ to: ~p" /#{ query } " ]
2629 end
2730 end
2831 rescue
You can’t perform that action at this time.
0 commit comments