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.

Motivation

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.

Demo

Documentation

Specification

Specification link


Specification being incubated in a Community Group

Status in Chromium

Blink


Enabled by default (tracking bug)

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

Owner

Intent to Prototype url

Intent to Prototype thread

Comments

This work is in support of the service worker scopes pattern matching feature: https://www.chromestatus.com/feature/5519762375311360

Last updated on 2021-11-08