urlpattern-polyfill icon indicating copy to clipboard operation
urlpattern-polyfill copied to clipboard

Fails to parse hostname correctly on Chrome

Open rotu opened this issue 1 year ago • 2 comments

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?

rotu avatar Aug 02 '24 21:08 rotu

I would say, as this is a polyfill this merely intends to add missing API:s, not fixing bugs in existing ones

voxpelli avatar Aug 03 '24 08:08 voxpelli

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.

rotu avatar Aug 03 '24 20:08 rotu

We talked this through, and agree that its not the place of the polyfill to fix browser implementations

SanderElias avatar May 08 '25 13:05 SanderElias