Fix redirect from / to /packages breaking browser back button (#248)

Previously, navigating to https://search.nixos.org/ would use history.pushState
to redirect to /packages and add a new entry to the browser history.
This meant that if you pressed the back button, you would navigate back to /
which would of course then redirect to /packages again.

Now history.replaceState is used instead of pushState, so the / history entry
is replaced entirely by a /packages history entry and the back button works.
This commit is contained in:
Bradley Walters 2020-12-07 00:53:56 -07:00 committed by GitHub
parent ba3fe60808
commit bae5a92131
Failed to generate hash of commit

View file

@ -202,7 +202,7 @@ changeRouteTo currentModel url =
Route.Home -> Route.Home ->
-- Always redirect to /packages until we have something to show -- Always redirect to /packages until we have something to show
-- on the home page -- on the home page
( model, Browser.Navigation.pushUrl model.navKey "/packages" ) ( model, Browser.Navigation.replaceUrl model.navKey "/packages" )
Route.Packages searchArgs -> Route.Packages searchArgs ->
let let