Repository navigation
fix(react-router): restore masked locations in hash history - #15771
Merged
brophdawg11 merged 2 commits intoNov 20, 2026
Merged
brophdawg11 merged 2 commits into
brophdawg11 merged 2 commits into
Conversation
push and replace write the mask into the URL and the router location into history.state.masked for every URL history, but createHashLocation never read it back. With createHashRouter and <Link mask>, Back/Forward to a masked entry rendered the mask URL's route and location.mask was undefined. Read state.masked the way createBrowserLocation does.
brophdawg11
approved these changes
Nov 20, 2026
brophdawg11
left a comment
Contributor
There was a problem hiding this comment.
The hash-history read now follows createBrowserHistory’s masked-location behavior. The regressions cover push/replace and Back/Forward, preserving the visible mask and router location.
Authored by an AI agent on behalf of @brophdawg11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shared
push/replaceingetUrlBasedHistorywrite the mask into the URL (history.createHref(location.mask || location)) and the router location intohistory.state.masked, for every URL history.createBrowserLocationreadsstate.maskedback (added with<Link unstable_mask>in #14716).createHashLocationonly parseswindow.location.hash, so a hash history hands back the mask URL as the location withmask: undefined. That happens right after the push (history.location) and on every POP.With
createHashRouterand<Link to="/gallery?photo=123" mask="/images/123">, the click renders the gallery with the modal. Back/Forward to that entry renders the/images/:idroute (the full image page) anduseLocation().maskis undefined. The same app oncreateBrowserRoutergoes back to the gallery + modal.maskis documented for Data and Framework modes, andcreateHashRouteris a Data mode router.I ran the built
packages/react-routerdist in jsdom (React 19.2.7, Node v22.23.3) with routes/,/gallery,/images/:id,/other: click the link, navigate to/other,history.back(). 3 runs, identical each time.This copies the browser history's read into
createHashLocation. Whenhistory.state.maskedis set, that is the location, and the path parsed from the hash (after the existing leading-/normalisation) is passed asmask.history.tsis +3/-1.router.tsandlib.tsxare untouched: the router already pushes the mask and readshistory.locationon POP, and<Link mask>builds its href with the hash history'screateHref.Entries without a mask go through the same code as before and keep
maskundefined.Two new tests in
hash-test.tsundera hash history→push a masked location: "shows the mask in the URL and keeps the router location" and "restores the router location on POP" (push masked, push/other,go(-1)). Both fail onmain:Both pass on the branch. Typecheck (
pnpm run --filter react-router typecheck) is 0 errors onmainand on the branch, and eslint, prettier andchanges:validatepass.Full
pnpm build && pnpm teston the branch: 3443 passed, 3 failed, 15 skipped. All 3 failures are inspecial-characters-test.tsx, and that spec also fails on unmodifiedmain(a different 2-3 of its param tests each run, across 3 runs).