Repository navigation
Support sites served from an IPv6 address - #6
Merged
Merged
Conversation
new URL(...).hostname reports an IPv6 host in brackets, e.g. "[2001:db8::1]". isValidHostname() accepted only IPv4 and DNS names, so a page served from an IPv6 address (a router's admin page, a home server) was treated as having no valid site: hostFromPattern() could not read its host back, and a rule could not name it. originPatternsFor() also built "*://*.[2001:db8::1]/*" for it, which is not a valid match pattern, so asking for site access would fail. Bracketed IPv6 literals are now valid hostnames (checked with the URL parser), and IP addresses of either family get only the exact-host pattern. Co-authored-by: Claude <noreply@anthropic.com>
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.
new URL(...).hostnamereports an IPv6 host in brackets, e.g.[2001:db8::1]. Two problems followed:isValidHostname()accepted only IPv4 addresses and DNS names, so a page served from an IPv6 address (a router's admin page, a home server) had no valid site.hostFromPattern()couldn't read its host back, and a rule couldn't name it.originPatternsFor()built*://*.[2001:db8::1]/*for it, which isn't a valid match pattern, so asking for site access would fail.Fix: bracketed IPv6 literals are valid hostnames (checked with the URL parser), and IP addresses of either family get only the exact-host pattern, as IPv4 already did.
Tests in
tests/unit/domain.test.ts:hostFromPattern()All three fail on
main. Typecheck, lint and Prettier are clean.npm test: 221 passed.Co-authored-by: Claude noreply@anthropic.com