Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Consider this a failure, leading to the `install` handler failing, if
// we get back an invalid response.
if (!isValidResponse) {
throw new WorkboxError('bad-precaching-response', {
url,
status: response.status,
});
}
// Redirected responses cannot be used to satisfy a navigation request, so
// any redirected response must be "copied" rather than cloned, so the new
// response doesn't contain the `redirected` flag. See:
// https://bugs.chromium.org/p/chromium/issues/detail?id=669363&desc=2#c1
if (response.redirected) {
response = await copyResponse(response);
}
await cacheWrapper.put({
event,
plugins,
response,
// `request` already uses `url`. We may be able to reuse it.
request: cacheKey === url ? request : new Request(cacheKey),
cacheName: this._cacheName,
matchOptions: {
ignoreSearch: true,
},
});
}