Constructor

RegExpRoute

new RegExpRoute(input)

Constructor for RegExpRoute.

Parameter

input

Object

Extends
Route

Example

// Any requests that match the regular expression will match this route, with
// the capture groups passed along to the handler as an array via params.
const route = new workbox.routing.RegExpRoute({
  regExp: new RegExp('^https://example.com/path/to/(\\w+)'),
  handler: {
    handle: ({event, params}) => {
      // params[0], etc. will be set based on the regexp capture groups.
      // Do something that returns a Promise.<Response>, like:
      return caches.match(event.request);
    },
  },
});

const router = new workbox.routing.Router();
router.registerRoute({route});