Skip to content

Add opt-in WHATWG URL and URLSearchParams - #3094

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:webapi/url
Aug 20, 2026
Merged

lahma merged 1 commit into
sebastienros:mainfrom
lahma:webapi/url

Conversation

@lahma

@lahma lahma commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Part of the opt-in web API series (#3079): a full WHATWG URL Standard implementation — URL and URLSearchParams behind WebApiFeatures.Url (in Default). Not a System.Uri wrapper: the spec's basic URL parser state machine, host parsers and serializers, implemented from https://url.spec.whatwg.org/ and validated against web-platform-tests.

Conformance: the vendored WPT corpus passes with zero exclusions — all 891 parse rows of urltestdata.json and all 278 setter rows of setters_tests.json (snapshot at wpt 6745634413e4153144e23bc3e866d6b14d3e55e6, BSD-3 license included, SHA recorded beside the resources). The corpus drivers run against the parser directly (no engine per row), assert minimum row counts so an unembedded resource cannot green-wash, fail on stale exclusions, and were validated by mutation: a one-character serializer mutation fails 623 rows.

Layout: Jint/WebApi/Url/Parsing/ is a pure, engine-free parser library (no Engine/Realm/JsValue) — fetch will consume it for request-URL resolution and per-redirect-hop policy checks — with the JS binding in Jint/WebApi/Url/. Percent-encoding is one 128-entry flags table over the spec's nested encode sets with Rune-based UTF-8 (USVString semantics fall out); IPv4/IPv6 are the spec algorithms including the hex/octal/overflow rules and longest-zero-run serialization.

IDNA uses IdnMapping with an important precision: the URL Standard's own domain-to-ASCII step 4 returns an ASCII domain lowercased without consulting Unicode ToASCII at all (a web-compat rule, not an optimisation — pinned with the spec's own xn--8i7caa example), so IdnMapping is reached only for genuinely internationalized domains. Its known divergences from UTS-46-as-the-spec-wants (VerifyDnsLength not disableable, CheckHyphens, empty labels, ICU version skew, invariant-globalization mode) are documented on the class with a one-time fidelity probe (faß.de) — and on this machine's ICU, none of them cost a single WPT row. This is the same posture the engine takes toward CLDR in ECMA-402.

JS surface: constructor with base, URL.parse (null on failure), URL.canParse, all component accessors with the spec's stateOverride setter algorithms (including the fact — WPT-pinned — that a failing setter still commits the components parsed before the failure), origin with the blob: re-parse rule, live-synced searchParams (update steps in both directions), delete(name, value)/has(name, value), stable code-unit sort, size, full iteration with @@iterator === entries. URLPattern and createObjectURL are absent, not throwing, so feature detection works. Subclassing works via OrdinaryCreateFromConstructor.

One hazard found in self-review and fixed with a regression test: using var on a mutable struct parser ran Dispose on a defensive copy, double-returning a pooled buffer; replaced with explicit try/finally and a test that forces the buffer-growth path.

Verified: all-TFM build, both suites × both frameworks × both host-contract-verification configurations; the WPT corpus green as above.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lahma
lahma merged commit 46615b6 into sebastienros:main Aug 20, 2026
5 checks passed
@lahma
lahma deleted the webapi/url branch August 20, 2026 17:41
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