fix(browser): normalize a bare [::1] address-bar entry to http:// - #382
Open
dormouse-bot wants to merge 1 commit into
Open
fix(browser): normalize a bare [::1] address-bar entry to http://#382dormouse-bot wants to merge 1 commit into
dormouse-bot wants to merge 1 commit into
Conversation
Deploying mouseterm with
|
| Latest commit: |
bba7ffd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fc9c18e0.mouseterm.pages.dev |
| Branch Preview URL: | https://fix-nav-url-bracketed-ipv6.mouseterm.pages.dev |
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.
normalizeNavUrlextracts the hostname from a schemeless authority withauthority.split(':', 1)[0], which returns[for a bracketed IPv6 literal — every colon in[::1]is part of the address, not a port separator. SoisLoopbackHostname('[')is false and a bare[::1]typed in the browser address bar is normalized tohttps://[::1], which just SSL-errors. The fix pulls the host through the closing bracket instead, keeping the exact formisLoopbackHostnamealready lists.Verified by the added test, which fails on
main(expected 'https://[::1]' to be 'http://[::1]') and passes with the fix.Scope and why it was invisible
isLoopbackHostnameexplicitly enumerates both'::1'and'[::1]', so handling the bracketed form is the documented intent — the authority parsing is what defeats it. Only the no-port case was broken:[::1]:5173already resolved to http via the/:\d+$/port branch, which is why the existingloopbackPort('http://[::1]:8080/')test passes and nothing caught this.loopbackPortitself was never affected — it goes throughnew URL, whose.hostnameis already unbracketed.The regression test pins all three forms (
[::1],[::1]/app?q=1,[::1]:5173) plus a non-loopback literal ([2001:db8::1]→ https) so the bracket handling can't be loosened into "all IPv6 is loopback".Ran:
browser-url.test.ts(18 passed), the fullsrc/components/wallsuite (23 files, 274 passed), andtsc --noEmitclean.