123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 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}' only partially matched ` +
- `against the cross-origin URL '${url}'. 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 };
|