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

feat: case-insensitive match for pathname

Open Sayan751 opened this issue 3 years ago • 4 comments

Related to https://github.com/WICG/urlpattern/issues/148. This PR adds support for case-insensitive match for pathname. It adds a caseSensitivePath flag to the init object.

Example:

import { strictEqual } from 'assert';

const pattern = new URLPattern({ pathname: '/home', caseSensitivePath: false });

const url = new URL('https://example.com/home');
strictEqual(pattern.test(url.href), true, url.href);

url.pathname = '/HOME';
strictEqual(pattern.test(url.href), true, url.href);

Sayan751 avatar Jun 22 '22 16:06 Sayan751

We are matching the spec so maybe file an issue on the spec as well?

kenchris avatar Jun 22 '22 18:06 kenchris

We are matching the spec so maybe file an issue on the spec as well?

Thanks! I am continuing the discussion already in the linked issue.

Sayan751 avatar Jun 22 '22 18:06 Sayan751

Note, I think we should land WPT changes upstream in chromium or wpt before bringing them here. Chromium will auto-sync to wpt and other browsers, but we don't have that setup for the polyfill repo.

And thanks to @Sayan751 for working on this!

wanderview avatar Jul 14 '22 20:07 wanderview

This looks good to me, have the upstream WPT changed landed @wanderview ?

I am fine with landing this and making a new release.

kenchris avatar Aug 12 '22 09:08 kenchris

ping @wanderview

kenchris avatar Aug 23 '22 08:08 kenchris

No they have not. Sorry, for the delay.

wanderview avatar Aug 23 '22 14:08 wanderview

@wanderview so you want me to wait with landing this until that has landed right?

kenchris avatar Aug 23 '22 14:08 kenchris

I think that would be best. I'll try to get to the upstream work this week.

wanderview avatar Aug 23 '22 14:08 wanderview

Note, I think I'm going to simplify the test changes in my upstream CL. I don't think we need this many test cases for ignoreCase.

wanderview avatar Aug 31 '22 15:08 wanderview

The spec changes have landed and I have sent the intent to ship in chrome M107 here:

https://groups.google.com/a/chromium.org/g/blink-dev/c/KgAdo3kB1wc/m/UN70zkeNAwAJ

Note, I recommend using the WPT tests from here instead of the WPT tests currently in this PR:

https://github.com/web-platform-tests/wpt/commit/6d152e4018ca4f45ce93eea4985c516a518c3ad6

Unfortunately I'm not sure how to make this big of a change on someone else's PR.

wanderview avatar Sep 28 '22 15:09 wanderview

Hi @Sayan751 do you want to update your PR? Or do you want us to redo it and give you credit?

kenchris avatar Sep 28 '22 15:09 kenchris

@kenchris I am sorry for this, but I have no time to update the PR. Please feel free to make the changes as you see fit.

Sayan751 avatar Sep 28 '22 16:09 Sayan751

We could just land this and then do a fast follow-up to sync the upstream WPT json file.

wanderview avatar Sep 28 '22 17:09 wanderview

Sure. Let's do that.

kenchris avatar Sep 28 '22 18:09 kenchris

I will file an issue to track it

kenchris avatar Sep 28 '22 18:09 kenchris

OK filed https://github.com/kenchris/urlpattern-polyfill/issues/106

kenchris avatar Sep 28 '22 18:09 kenchris