serwist
Version:
A Swiss Army knife for service workers.
56 lines • 2.17 kB
TypeScript
import { Route } from "./Route.js";
import type { RouteHandler } from "./types.js";
export interface NavigationRouteMatchOptions {
/**
* If any of these patterns
* match the URL's pathname and search parameter, the route will handle the
* request (assuming the denylist doesn't match).
*
* @default [/./]
*/
allowlist?: RegExp[];
/**
* If any of these patterns match, the route will not handle the request (even if a allowlist RegExp matches).
*/
denylist?: RegExp[];
}
/**
* A class that makes it easy to create a {@linkcode Route} object that matches navigation requests.
*
* It will only match incoming requests whose [`mode`](https://fetch.spec.whatwg.org/#concept-request-mode) is set to `"navigate"`.
*
* You can optionally only apply this route to a subset of navigation requests
* by using one or both of the `denylist` and `allowlist` parameters.
*/
export declare class NavigationRoute extends Route {
private readonly _allowlist;
private readonly _denylist;
/**
* If both `denylist` and `allowlist` are provided, `denylist` will
* take precedence.
*
* The regular expressions in `allowlist` and `denylist`
* are matched against the concatenated
* [`pathname`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname)
* and [`search`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search)
* portions of the requested URL.
*
* *Note*: These RegExps may be evaluated against every destination URL during
* a navigation. Avoid using
* [complex RegExps](https://github.com/GoogleChrome/workbox/issues/3077),
* or else your users may see delays when navigating your site.
*
* @param handler A callback function that returns a `Promise` resulting in a `Response`.
* @param options
*/
constructor(handler: RouteHandler, { allowlist, denylist }?: NavigationRouteMatchOptions);
/**
* Routes match handler.
*
* @param options
* @returns
* @private
*/
private _match;
}
//# sourceMappingURL=NavigationRoute.d.ts.map