RegExpRoute.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. import { RouteHandler } from 'workbox-core/types.js';
  2. import { HTTPMethod } from './utils/constants.js';
  3. import { Route } from './Route.js';
  4. import './_version.js';
  5. /**
  6. * RegExpRoute makes it easy to create a regular expression based
  7. * {@link workbox-routing.Route}.
  8. *
  9. * For same-origin requests the RegExp only needs to match part of the URL. For
  10. * requests against third-party servers, you must define a RegExp that matches
  11. * the start of the URL.
  12. *
  13. * @memberof workbox-routing
  14. * @extends workbox-routing.Route
  15. */
  16. declare class RegExpRoute extends Route {
  17. /**
  18. * If the regular expression contains
  19. * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},
  20. * the captured values will be passed to the
  21. * {@link workbox-routing~handlerCallback} `params`
  22. * argument.
  23. *
  24. * @param {RegExp} regExp The regular expression to match against URLs.
  25. * @param {workbox-routing~handlerCallback} handler A callback
  26. * function that returns a Promise resulting in a Response.
  27. * @param {string} [method='GET'] The HTTP method to match the Route
  28. * against.
  29. */
  30. constructor(regExp: RegExp, handler: RouteHandler, method?: HTTPMethod);
  31. }
  32. export { RegExpRoute };