Repository navigation
fix: follow nav redirects - #92
Merged
Merged
Conversation
A link that redirects, such as /blog/post to /blog/post/, kept its old URL after a client navigation, so the address bar and relative URLs did not match the page. The client now commits the final URL with precommitHandler, or loads the page when the URL is already committed.
bongo:navigate fired from the fetch, so it came before the URL changed in a browser with precommitHandler, and after it in others and on back and forward. It now fires in the navigate listener, for every navigation: before the URL changes and before the fetch.
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
A link that the server redirects, such as
/blog/postto/blog/post/, kept its first URL after a client navigation. The address bar, the history entry, and each relative URL of the page then did not match the page, as they would after a full-page load.html.read()gives a page: its HTML, and the URL of the last response, with the hash of the link, since a request carries no hash. Prefetch keeps the same page, and resolves the stylesheets of a page against its final URL.NavigationPrecommitController, the client fetches the page inprecommitHandler, and callscontroller.redirect()when the URL changed. The URL then commits as the final one, before the swap. Traverse navigations, and browsers withoutprecommitHandler, get a full-page load of the final URL when a response was redirected, as the client already does for a response that is not HTML.bongo:navigatefires in thenavigatelistener, for every navigation, so it always comes before the URL changes and before the fetch. Onmain, it came after the URL changed. After a redirect,bongo:navigategets the URL of the link, andbongo:replace,bongo:replaced, andbongo:navigatedget the final URL.Performance
mainagainst this branch, in both orders: median 297.4 ms / 294.4 ms, then 298.1 ms / 297.7 ms. No change; the fade transition is most of it.bun run bench site: 2.35 s, against 2.34 s onmain. No change.Test plan
precommitHandlerstub)precommitHandler, a redirect loads the final URLbongo:navigatesees the old URL inlocation, with and withoutprecommitHandler, and on back and forward (fails on the first commit of this PR)bun run build,bun test,bunx tsc -p .,bunx tsc -p build