12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import { assert } from 'workbox-core/_private/assert.js';
- import { logger } from 'workbox-core/_private/logger.js';
- import { Route } from './Route.js';
- import './_version.js';
- class RegExpRoute extends Route {
-
- constructor(regExp, handler, method) {
- if (process.env.NODE_ENV !== 'production') {
- assert.isInstance(regExp, RegExp, {
- moduleName: 'workbox-routing',
- className: 'RegExpRoute',
- funcName: 'constructor',
- paramName: 'pattern',
- });
- }
- const match = ({ url }) => {
- const result = regExp.exec(url.href);
-
- if (!result) {
- return;
- }
-
-
-
-
- if (url.origin !== location.origin && result.index !== 0) {
- if (process.env.NODE_ENV !== 'production') {
- logger.debug(`The regular expression '${regExp.toString()}' only partially matched ` +
- `against the cross-origin URL '${url.toString()}'. RegExpRoute's will only ` +
- `handle cross-origin requests if they match the entire URL.`);
- }
- return;
- }
-
-
-
-
- return result.slice(1);
- };
- super(match, handler, method);
- }
- }
- export { RegExpRoute };
|