Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 771 Bytes

howto.md

File metadata and controls

19 lines (14 loc) · 771 Bytes

How to use the URLPattern API

The URLPattern API is currently available in Chrome 93 and later behind a flag.

  1. Download Chrome (Android, Desktop).
  2. Navigate to chrome://flags and enable Experimental Web Platform features.
  3. Visit a page that uses URLPattern, such as the demo on glitch.

Here is an example of how to use the API:

const pattern = new URLPattern({ pathname: '/:product/index.html' });
const result = pattern.exec(someURL);
if (result) {
  handleProduct(result.pathname.groups.product);
}

More code examples can be found in the URLPattern documentation.