Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/workbox-precaching/src/PrecacheController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ class PrecacheController {
printCleanupDetails(deletedURLs);
}

return {deletedURLs};
return {
deletedURLs,
deletedCacheRequests: deletedURLs,
};
});
}

Expand Down
11 changes: 9 additions & 2 deletions packages/workbox-precaching/src/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export interface InstallResult {
}

export interface CleanupResult {
deletedURLs: string[];
/**
* @deprecated Use `deletedURLs` instead.
* TODO: Remove in the next major release.
*/
deletedCacheRequests: string[];
}

Expand Down Expand Up @@ -51,8 +56,10 @@ export type urlManipulation = ({url}: {url: URL}) => URL[];

/**
* @typedef {Object} CleanupResult
* @property {Array<string>} deletedCacheRequests List of URLs that were deleted
* while cleaning up the cache.
* @property {Array<string>} deletedURLs List of URLs that were deleted while
* cleaning up the cache.
* @property {Array<string>} deletedCacheRequests Deprecated alias for
* deletedURLs.
*
* @memberof workbox-precaching
*/
Expand Down
8 changes: 8 additions & 0 deletions test/workbox-precaching/sw/test-PrecacheController.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,13 @@ describe(`PrecacheController`, function () {
activateEvent,
);
expect(cleanupDetailsTwo.deletedURLs.length).to.equal(1);
expect(cleanupDetailsTwo.deletedCacheRequests.length).to.equal(1);
expect(cleanupDetailsTwo.deletedURLs[0]).to.eql(
`${location.origin}/scripts/index.js?__WB_REVISION__=1234`,
);
expect(cleanupDetailsTwo.deletedCacheRequests[0]).to.eql(
`${location.origin}/scripts/index.js?__WB_REVISION__=1234`,
);

const keysTwo = await cache.keys();
expect(keysTwo.length).to.equal(cacheListTwo.length);
Expand Down Expand Up @@ -894,6 +898,10 @@ describe(`PrecacheController`, function () {
`${location.origin}/index.1234.html`,
`${location.origin}/scripts/stress.js?test=search&foo=bar&__WB_REVISION__=1234`,
]);
expect(cleanupDetailsTwo.deletedCacheRequests).to.have.members([
`${location.origin}/index.1234.html`,
`${location.origin}/scripts/stress.js?test=search&foo=bar&__WB_REVISION__=1234`,
]);

const keysTwo = await cache.keys();
expect(keysTwo.length).to.equal(cacheListTwo.length);
Expand Down
Loading