123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import { logger } from 'workbox-core/_private/logger.js';
- import { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';
- import { Route } from 'workbox-routing/Route.js';
- import { generateURLVariations } from './utils/generateURLVariations.js';
- import './_version.js';
- class PrecacheRoute extends Route {
-
- constructor(precacheController, options) {
- const match = ({ request, }) => {
- const urlsToCacheKeys = precacheController.getURLsToCacheKeys();
- for (const possibleURL of generateURLVariations(request.url, options)) {
- const cacheKey = urlsToCacheKeys.get(possibleURL);
- if (cacheKey) {
- const integrity = precacheController.getIntegrityForCacheKey(cacheKey);
- return { cacheKey, integrity };
- }
- }
- if (process.env.NODE_ENV !== 'production') {
- logger.debug(`Precaching did not find a match for ` + getFriendlyURL(request.url));
- }
- return;
- };
- super(match, precacheController.strategy);
- }
- }
- export { PrecacheRoute };
|