Skip to content

Support sites served from an IPv6 address - #6

Merged
Dszae merged 1 commit into
mainfrom
fix/ipv6-hosts
Nov 23, 2026
Merged

Dszae merged 1 commit into
mainfrom
fix/ipv6-hosts

Conversation

@Dszae

@Dszae Dszae commented Nov 23, 2026

Copy link
Copy Markdown
Owner

new URL(...).hostname reports 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:

  • IPv6 validation, including malformed literals
  • the exact-host pattern for an IPv6 address
  • a host → pattern → host round trip through hostFromPattern()

All three fail on main. Typecheck, lint and Prettier are clean. npm test: 221 passed.

Co-authored-by: Claude noreply@anthropic.com

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>
@Dszae
Dszae merged commit 45ff261 into main Nov 23, 2026
2 checks passed
@Dszae
Dszae deleted the fix/ipv6-hosts branch November 23, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant