From 4f0e7153f7a8bcf85fa12715f7ffd79d53e24ca4 Mon Sep 17 00:00:00 2001 From: Roderick Date: Thu, 17 Oct 2024 20:00:30 -0700 Subject: [PATCH] Fix service worker not installing issue --- entab-js/example/index.html | 2 +- entab-js/example/service-worker.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/entab-js/example/index.html b/entab-js/example/index.html index 35b06d6..9f86d0a 100644 --- a/entab-js/example/index.html +++ b/entab-js/example/index.html @@ -75,7 +75,7 @@ // set up service worker so this page can be installable if ("serviceWorker" in navigator) { window.addEventListener("load", function() { - navigator.serviceWorker.register("/service-worker.js"); + navigator.serviceWorker.register("./service-worker.js"); }); } diff --git a/entab-js/example/service-worker.js b/entab-js/example/service-worker.js index 33aab90..224d292 100644 --- a/entab-js/example/service-worker.js +++ b/entab-js/example/service-worker.js @@ -1,7 +1,7 @@ self.addEventListener('install', evt => { evt.waitUntil( caches.open('entab').then(cache => { - return cache.add('/index.html').then(() => self.skipWaiting()); + return cache.add('./index.html').then(() => self.skipWaiting()); }) ) }); @@ -10,10 +10,10 @@ self.addEventListener('activate', evt => { evt.waitUntil(self.clients.claim()); }); -self.addEventListener("fetch", evt => { +self.addEventListener('fetch', evt => { // fix for the bug here: https://bugs.chromium.org/p/chromium/issues/detail?id=823392 - if (evt.request.cache === "only-if-cached" && evt.request.mode !== "same-origin") { - return + if (evt.request.cache === 'only-if-cached' && evt.request.mode !== 'same-origin') { + return; } evt.respondWith(