Skip to content

Commit

Permalink
Fix service worker not installing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bovee committed Oct 18, 2024
1 parent 46f050b commit 4f0e715
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion entab-js/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}

Expand Down
8 changes: 4 additions & 4 deletions entab-js/example/service-worker.js
Original file line number Diff line number Diff line change
@@ -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());
})
)
});
Expand All @@ -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(
Expand Down

0 comments on commit 4f0e715

Please sign in to comment.