Skip to content

Add URLPattern (WHATWG) for JS-parity URL matching - #93

Open
kblok wants to merge 1 commit into
mainfrom
feat/urlpattern-core
Open

kblok wants to merge 1 commit into
mainfrom
feat/urlpattern-core

Conversation

@kblok

@kblok kblok commented Oct 6, 2026

Copy link
Copy Markdown
Member

Playwright for Node accepts a URLPattern wherever it takes a URL matcher, and .NET has nothing like it. This adds PlaywrightNative.URLPattern, a port of the WHATWG URL Pattern standard with no external package: constructors from a pattern string or URLPatternInit, the component getters, HasRegExpGroups, Test and Exec.

Matching needs WHATWG URL canonicalization, and System.Uri does not follow those rules, so a small WHATWG URL parser (hosts, IDNA, IPv4/IPv6, paths, percent-encoding) lives next to it. Custom regexp groups are written in JavaScript "v"-flag syntax and are translated to .NET Regex, keeping JS group numbering.

The WPT urlpatterntestdata.json is vendored with its BSD license and runs as a browser-free test: 365 of 369 entries pass. Three entries call the JS API in ways the .NET overloads can't express, and one differs only in an empty optional group reading "" instead of undefined.

This is part 1 of 3. Routing and waits/expect wiring follow.

Part of #42, #47, #28

🤖 Generated with Claude Code

A port of the WHATWG URL Pattern standard with no external package: the
pattern tokenizer and parser, regex and pattern-string generation, the
constructor-string parser, and component canonicalization on top of a
small WHATWG URL parser (System.Uri is not WHATWG-compliant). Custom regexp
groups are translated from JavaScript "v"-flag syntax to .NET Regex.

Vendors the WPT urlpatterntestdata.json (BSD-3-Clause) and runs it as a
browser-free data-driven test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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