Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return entry.async("arraybuffer").then((file) => {
let zipResponse = new Response(file, {
"status" : 200,
"headers": { 'Content-Type': mimeType }
});
let zipResponseClone = zipResponse.clone();
caches.open(cacheName).then((cache) => {
return cache.put(originalRequest.url, zipResponseClone);
}).then(() => {
console.log("from cached zip");
});
return zipResponse;
});
} else {
this.zip = new JSZip();
return fetch(url).then((epubResponse) => {
return epubResponse.arrayBuffer();
}).then((buffer) => {
return this.zip.loadAsync(buffer);
}).then(() => {
entry = this.zip.file(path);
mimeType = mime.lookup(entry.name);
return entry.async("arraybuffer");
}).then((file) => {
let zipResponse = new Response(file, {
"status" : 200,
"headers": { 'Content-Type': mimeType }
});
let zipResponseClone = zipResponse.clone();
caches.open(cacheName).then((cache) => {
return cache.put(originalRequest.url, zipResponseClone);