diff --git a/web/manifest.json b/web/manifest.json index a9cb4f5..3d1bf8b 100644 --- a/web/manifest.json +++ b/web/manifest.json @@ -2,8 +2,8 @@ "name": "Binary Bloom Clock", "short_name": "Binary Clock", "description": "A beautifully designed binary clock that displays time using binary lights. Read the time in 24-hour or 12-hour format.", - "start_url": "/", - "scope": "/", + "start_url": "./index.html", + "scope": "./", "display": "standalone", "orientation": "portrait-primary", "theme_color": "#4a2954", @@ -36,7 +36,7 @@ "name": "24-Hour View", "short_name": "24h", "description": "Open Binary Clock in 24-hour mode", - "url": "/?mode=24", + "url": "./?mode=24", "icons": [ { "src": "data:image/svg+xml,24h", @@ -49,7 +49,7 @@ "name": "12-Hour View", "short_name": "12h", "description": "Open Binary Clock in 12-hour mode", - "url": "/?mode=12", + "url": "./?mode=12", "icons": [ { "src": "data:image/svg+xml,12h", diff --git a/web/service-worker.js b/web/service-worker.js index d77be0d..e52c596 100644 --- a/web/service-worker.js +++ b/web/service-worker.js @@ -1,12 +1,14 @@ const CACHE_NAME = 'binary-bloom-v1'; const ASSETS_TO_CACHE = [ - '/', - '/index.html', - '/styles.css', - '/script.js', - '/manifest.json' + './', + './index.html', + './styles.css', + './script.js', + './manifest.json' ]; +const APP_SCOPE_PATH = new URL(self.registration.scope).pathname; + // Install event - cache assets self.addEventListener('install', event => { event.waitUntil( @@ -47,7 +49,7 @@ self.addEventListener('fetch', event => { // Network first for API calls, cache first for assets const url = new URL(event.request.url); - if (url.pathname === '/' || url.pathname.endsWith('.html') || + if (url.pathname === APP_SCOPE_PATH || url.pathname.endsWith('.html') || url.pathname.endsWith('.css') || url.pathname.endsWith('.js') || url.pathname.endsWith('.json')) {