Skip to content

Commit

Permalink
Handle redirects to absolute URLs on fetch response.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonkearns committed Apr 15, 2024
1 parent 35dc5ab commit 2e7c5d1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Pages/Internal/Platform.elm
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,17 @@ update config appMsg model =
ProcessFetchResponse transitionId response toMsg ->
case response of
Ok ( _, ResponseSketch.Redirect redirectTo ) ->
( model, NoEffect )
|> startNewGetLoad (currentUrlWithPath redirectTo model) toMsg
let
isAbsoluteUrl : Bool
isAbsoluteUrl =
Url.fromString redirectTo /= Nothing
in
if isAbsoluteUrl then
( model, BrowserLoadUrl redirectTo )

else
( model, NoEffect )
|> startNewGetLoad (currentUrlWithPath redirectTo model) toMsg

_ ->
update config (toMsg response) (clearLoadingFetchersAfterDataLoad transitionId model)
Expand Down

0 comments on commit 2e7c5d1

Please sign in to comment.