URLPattern is a new web API that provides native support for matching URLs given a pattern string. It is designed to be usable both in javascript directly and by passing patterns to other web platform APIs; e.g. as a service worker scope.
Both web platform features and javascript applications often need to match against URLs. For example, service worker scopes on the web platform side and URL routing in a javascript framework. Past web platform features have individually created their own URL matching mechanism. Javascript has relied on libraries such as path-to-regexp. This effort introduces a common URL matching primitive that can be used in both web platform APIs and directly in javascript.
Docs: https://web.dev/urlpattern/ https://github.com/WICG/urlpattern/blob/main/mdn-drafts/QUICK-REFERENCE.md https://docs.google.com/document/d/17L6b3zlTHtyxQvOAvbK55gQOi5rrJLERwjt_sKXpzqc/edit?usp=sharing
Samples: https://glitch.com/~urlpattern-sw-routing
Explainers: https://github.com/WICG/urlpattern/blob/master/explainer.md