URLPattern Link to heading

The URLPattern API provides a web platform primitive for matching URLs based on a convenient pattern syntax

It supports thinks like the following (and more)

  • Literal route matches /route
  • Wildcards /posts/*
  • Named gorups /posts/:id

exec vs test Link to heading

Both of these are methods of a URLPattern object that can be used to match the pattern against an url (for example, one coming from an HTTP request)

  • exec() returns an object with the matched parts of the URL, or null
  • test() returns true/false whether the url matches