Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore fbclid by default when matching precached URLs #2532

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/workbox-build/src/generate-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const writeServiceWorkerUsingDefaultTemplate =
* definition of `strict` in the `glob`
* [documentation](https://github.com/isaacs/node-glob#options).
*
* @param {Array<RegExp>} [config.ignoreURLParametersMatching=[/^utm_/]]
* @param {Array<RegExp>} [config.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]]
* Any search parameter names that match against one of the RegExp in this array
* will be removed before looking for a precache match. This is useful if your
* users might request URLs that contain, for example, URL parameters used to
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-precaching/src/PrecacheController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PrecacheController {
* @param {string} [options.directoryIndex=index.html] The `directoryIndex`
* will check cache entries for a URLs ending with '/' to see if there is a
* hit when appending the `directoryIndex` value.
* @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
* @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]] An
* array of regex's to remove search params when looking for a cache match.
* @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
* check the cache for the URL with a `.html` added to the end of the end.
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-precaching/src/addRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import './_version.js';
* @param {string} [options.directoryIndex=index.html] The `directoryIndex` will
* check cache entries for a URLs ending with '/' to see if there is a hit when
* appending the `directoryIndex` value.
* @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
* @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]] An
* array of regex's to remove search params when looking for a cache match.
* @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
* check the cache for the URL with a `.html` added to the end of the end.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import '../_version.js';
* @memberof module:workbox-precaching
*/
export function* generateURLVariations(url: string, {
ignoreURLParametersMatching = [/^utm_/],
ignoreURLParametersMatching = [/^utm_/, /^fbclid$/],
directoryIndex = 'index.html',
cleanURLs = true,
urlManipulation,
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-webpack-plugin/src/generate-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class GenerateSW {
* @param {Array<string>} [config.excludeChunks] One or more chunk names whose
* corresponding output files should be excluded from the precache manifest.
*
* @param {Array<RegExp>} [config.ignoreURLParametersMatching=[/^utm_/]]
* @param {Array<RegExp>} [config.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]]
* Any search parameter names that match against one of the RegExp in this array
* will be removed before looking for a precache match. This is useful if your
* users might request URLs that contain, for example, URL parameters used to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ describe(`[workbox-precaching] Precache and Update`, function() {
requestCounter = global.__workbox.server.startCountingRequests();

// Request the page and check that the precached assets weren't requested from the network.
// Include the default ignoreURLParametersMatching query parameters.
await global.__workbox.webdriver.get(`${baseURL}index.html`);
await global.__workbox.webdriver.get(`${baseURL}index.html?utm_source=test`);
await global.__workbox.webdriver.get(`${baseURL}index.html?^fbclid$=test`);
jeffposnick marked this conversation as resolved.
Show resolved Hide resolved

expect(requestCounter.getURLCount('/test/workbox-precaching/static/precache-and-update/')).to.eql(0);
expect(requestCounter.getURLCount('/test/workbox-precaching/static/precache-and-update/index.html')).to.eql(0);
expect(requestCounter.getURLCount('/test/workbox-precaching/static/precache-and-update/index.html?utm_source=test')).to.eql(0);
expect(requestCounter.getURLCount('/test/workbox-precaching/static/precache-and-update/index.html?^fbclid$=test')).to.eql(0);
expect(requestCounter.getURLCount('/test/workbox-precaching/static/precache-and-update/styles/index.css')).to.eql(0);

// Unregister the old counter, and start a new count.
Expand Down