|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.5 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 | import { removeIgnoredSearchParams } from './removeIgnoredSearchParams.js';
|
|---|
| 9 | import '../_version.js';
|
|---|
| 10 | /**
|
|---|
| 11 | * Generator function that yields possible variations on the original URL to
|
|---|
| 12 | * check, one at a time.
|
|---|
| 13 | *
|
|---|
| 14 | * @param {string} url
|
|---|
| 15 | * @param {Object} options
|
|---|
| 16 | *
|
|---|
| 17 | * @private
|
|---|
| 18 | * @memberof workbox-precaching
|
|---|
| 19 | */
|
|---|
| 20 | export function* generateURLVariations(url, { ignoreURLParametersMatching = [/^utm_/, /^fbclid$/], directoryIndex = 'index.html', cleanURLs = true, urlManipulation, } = {}) {
|
|---|
| 21 | const urlObject = new URL(url, location.href);
|
|---|
| 22 | urlObject.hash = '';
|
|---|
| 23 | yield urlObject.href;
|
|---|
| 24 | const urlWithoutIgnoredParams = removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching);
|
|---|
| 25 | yield urlWithoutIgnoredParams.href;
|
|---|
| 26 | if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {
|
|---|
| 27 | const directoryURL = new URL(urlWithoutIgnoredParams.href);
|
|---|
| 28 | directoryURL.pathname += directoryIndex;
|
|---|
| 29 | yield directoryURL.href;
|
|---|
| 30 | }
|
|---|
| 31 | if (cleanURLs) {
|
|---|
| 32 | const cleanURL = new URL(urlWithoutIgnoredParams.href);
|
|---|
| 33 | cleanURL.pathname += '.html';
|
|---|
| 34 | yield cleanURL.href;
|
|---|
| 35 | }
|
|---|
| 36 | if (urlManipulation) {
|
|---|
| 37 | const additionalURLs = urlManipulation({ url: urlObject });
|
|---|
| 38 | for (const urlToAttempt of additionalURLs) {
|
|---|
| 39 | yield urlToAttempt.href;
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.