Repository navigation
fix: skip history.pushState - #90
Merged
Merged
Conversation
The client took each history.pushState or replaceState from a script as a navigation, and fetched the URL as a page: a widget that put its state in the URL lost it, and a URL with no page failed. Back or forward within one page also fetched it again. Now only a navigation to another page, or back or forward to an entry of another page, loads a page.
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.
Summary
The client took each
history.pushState()orhistory.replaceState()from a script as a navigation, and fetched the URL as a page. A tab or filter that wrote its state into the URL lost it, a script that stripsutm_*withreplaceStatereloaded the page, and a URL with no page failed. Back or forward between entries of one page also fetched the page again.Now the client works as the browser does without it:
pushorreplacewithdestination.sameDocumentcomes from the History API, so the client leaves it to the page. Links andnavigate()havesameDocument: false, and still go through the client.popstate. Back or forward to an entry of another page loads that page.Test plan
pushState('?tab=2'): before, eachpushState, back, and forward fetched the page and reset the tab; after, none fetch and the tab keeps its state. A client link, and back to an entry of another page, still fetch.bun run build,bun test(905 pass),bunx tsc -p .,bunx tsc -p build