-
Notifications
You must be signed in to change notification settings - Fork 24
Description
At the TPAC 2020 discussion @annevk suggested making service workers scopes only match against pathnames instead of the entire URL. This is related to the question of removing hostname matching in #19, but slightly different.
After thinking about the suggestion and what it would mean I am leaning towards doing this. My idea is to expose a separate interface:
let p = new URLPathnamePattern('/foo/*');
if (p.test(my-path)))
// do stuff
It would also take a baseURL for relative pathnames:
let p = new URLPathnamePattern('./*', self.location);
if (p.test(my-path)))
// do stuff
The full URLPattern and this URLPathnamePattern interface could share the same internal code for matching pathnames.
For lists we would need something like URLPathnamePatternList.
One notable change for the test() and exec() methods is they would no longer require a full parsable URL. Instead they would only require a pathname. For code that only has a pathname to begin with this would make the API easier to use instead of constructing full URLs just to wildcard all the non-path parts.
Service worker scopes would then take URLPathnamePattern or URLPathnamePatternList. This would cause service workers to lose the ability to match against any search string values, but I think we all agree that was an accidental feature and does not work well for real use cases.
My current plan is to prototype this kind of path-only interface in addition to URLPattern for use cases looking for full URL matching.