From 7e20e4c2976c79b82838abca82c6eb6f2b8c014d Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 21 Apr 2024 19:46:52 +0100 Subject: [PATCH] Some cleanup --- service-worker.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/service-worker.js b/service-worker.js index d2271771..dcfa9734 100644 --- a/service-worker.js +++ b/service-worker.js @@ -256,8 +256,6 @@ if (typeof chrome !== 'undefined' && chrome.action) { // Process install event self.addEventListener('install', function (event) { console.debug('[SW] Install Event processing'); - // DEV: We can't skip waiting because too many params are loaded at an early stage from the old file before the new one can activate... - // self.skipWaiting(); // We try to circumvent the browser's cache by adding a header to the Request, and it ensures all files are explicitly versioned var requests = precacheFiles.map(function (urlPath) { return new Request(urlPath + '?v' + appVersion, { cache: 'no-cache' }); @@ -275,6 +273,11 @@ self.addEventListener('install', function (event) { }); }) ); + // .then(function () { + // // DEV: We can't skip waiting because too many params are loaded at an early stage from the old file before the new one can activate... + // // console.warn('Attempting to skip waiting...'); + // // self.skipWaiting(); + // }); })); } }); @@ -352,7 +355,7 @@ self.addEventListener('fetch', function (event) { if (/\/dist\/(www|[^/]+?\.zim)\//.test(rqUrl) && !/\/dist\//.test(self.registration.scope)) return; // Filter darkReader request transformed by wombat.js if (/\.zim.*\/www\/(?:js\/(?:lib\/)?darkreader\.min\.js|.*-\/s\/style-dark(?:-invert)?\.css)/.test(rqUrl)) { - rqUrl = rqUrl.replace(/^([^:]+:\/\/[^\/]+(?:[^\/]|\/(?![^\/]+\.zim\/))+)(?:[^\/]|\/(?!www\/))+/, '$1'); + rqUrl = rqUrl.replace(/^([^:]+:\/\/[^/]+(?:[^/]|\/(?![^/]+\.zim\/))+)(?:[^/]|\/(?!www\/))+/, '$1'); } var urlObject = new URL(rqUrl); // Test the URL with parameters removed