Fails to parse hostname correctly on Chrome
URL parsing relies on the native URL implementation, which is buggy.
So new URLPattern({hostname:'example.com'}).test("foo://example.com") returns false in Chrome when using this polyfill. The root cause seems to be a noncompliant URL implementation: https://issues.chromium.org/issues/40063064
Maybe this should use https://www.npmjs.com/package/whatwg-url instead of the native implementation?
I would say, as this is a polyfill this merely intends to add missing API:s, not fixing bugs in existing ones
I would say, as this is a polyfill this merely intends to add missing API:s, not fixing bugs in existing ones
I agree for the most part.
The URLPattern spec refers to the "result of parsing" a string. That refers to the algorithm in the URL spec, not the URL global.
Indeed, this API should work even if you delete globalThis.URL, which is not the case.
We talked this through, and agree that its not the place of the polyfill to fix browser implementations