|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | Copyright 2019 Google LLC
|
|---|
| 3 |
|
|---|
| 4 | Use of this source code is governed by an MIT-style
|
|---|
| 5 | license that can be found in the LICENSE file or at
|
|---|
| 6 | https://opensource.org/licenses/MIT.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | import {getOrCreatePrecacheController} from './getOrCreatePrecacheController.js';
|
|---|
| 10 | import {generateURLVariations} from './generateURLVariations.js';
|
|---|
| 11 | import {PrecacheRouteOptions} from '../_types.js';
|
|---|
| 12 | import '../_version.js';
|
|---|
| 13 |
|
|---|
| 14 | /**
|
|---|
| 15 | * This function will take the request URL and manipulate it based on the
|
|---|
| 16 | * configuration options.
|
|---|
| 17 | *
|
|---|
| 18 | * @param {string} url
|
|---|
| 19 | * @param {Object} options
|
|---|
| 20 | * @return {string} Returns the URL in the cache that matches the request,
|
|---|
| 21 | * if possible.
|
|---|
| 22 | *
|
|---|
| 23 | * @private
|
|---|
| 24 | */
|
|---|
| 25 | export const getCacheKeyForURL = (
|
|---|
| 26 | url: string,
|
|---|
| 27 | options: PrecacheRouteOptions,
|
|---|
| 28 | ): string | void => {
|
|---|
| 29 | const precacheController = getOrCreatePrecacheController();
|
|---|
| 30 |
|
|---|
| 31 | const urlsToCacheKeys = precacheController.getURLsToCacheKeys();
|
|---|
| 32 | for (const possibleURL of generateURLVariations(url, options)) {
|
|---|
| 33 | const possibleCacheKey = urlsToCacheKeys.get(possibleURL);
|
|---|
| 34 | if (possibleCacheKey) {
|
|---|
| 35 | return possibleCacheKey;
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.