whatwg / urlpattern

URL Pattern Standard
https://urlpattern.spec.whatwg.org/
Other
154 stars 20 forks source link

Accept URL as the match algorithm's input. #218

Closed yoshisatoyanagisawa closed 6 months ago

yoshisatoyanagisawa commented 7 months ago

What is the issue with the URL Pattern Standard?

In the ServiceWorker static routing API (https://github.com/w3c/ServiceWorker/pull/1701), the match algorithm is used for matching with a request URL, which is a URL. However, the specification expects either of USVString or URLPatternInit as its input now.

To fill the gap, we may need to make the match algorithm accept URL.

yoshisatoyanagisawa commented 7 months ago

Since URL is struct, we may need to do https://github.com/whatwg/urlpattern/issues/217 before this?

jeremyroman commented 6 months ago

From a JS perspective, this works because URL suffices for a URLPatternInit dictionary (it exposes the necessary properties). If you're interested in calling this from another spec (rather than being concerned about the JS interface), maybe it would be convenient to have a spec helper which accepts URL records, sure.

yoshisatoyanagisawa commented 6 months ago

Just FYI, but it was pointed out in https://github.com/w3c/ServiceWorker/pull/1701/files#r1484898361 while calling match for the ServiceWorker static routing API.

yoshisatoyanagisawa commented 6 months ago

I have updated the description to clarify that the match algorithm change is needed for the SW static routing API. Making test() or exec() to accept the URL object is out of the scope because as @jeremyroman touched in https://github.com/whatwg/urlpattern/issues/218#issuecomment-1946247413, it is actually not needed for the external APIs.