English
RegExpRoute
Class @vite-pwa/workbox-swkit/routingRegExpRoute makes it easy to create a regular expression based workbox-routing.Route.
For same-origin requests the RegExp only needs to match part of the URL. For requests against third-party servers, you must define a RegExp that matches the start of the URL.
Constructor
ts
new RegExpRoute(regExp: RegExp, handler: RouteHandler, method?: HTTPMethod)If the regular expression contains [capture groups]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references, the captured values will be passed to the workbox-routing~handlerCallback params argument.
Parameters
regExp– The regular expression to match against URLs.handler– A callback function that returns a Promise resulting in a Response.method– The HTTP method to match the Route against.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
catchHandler? | RouteHandlerObject | ||
handler | RouteHandlerObject | ||
match | RouteMatchCallback | ||
method | HTTPMethod |
Methods
setCatchHandler()
ts
setCatchHandler(handler: RouteHandler): voidParameters
handler– A callback function that returns a Promise resolving to a Response