make URLs absolute relative to service worker location

Hunter
Wednesday, April 29th, 2026 at 9:14 PM

build.py+2-3

build.py
209  	console.log('Service Worker installing...', 'Base path:', basePath);
210  	event.waitUntil(
211  		caches.open(CACHE_NAME).then(cache => {{
    -			// Make URLs absolute relative to service worker location
212  			const absoluteUrls = STATIC_FILES.map(url => {{
    -				if (url === './') return basePath;
    -				return new URL(url, basePath + 'index.html').href;
213 +				if (url === './') return new URL(basePath, self.location.href).href;
214 +				return new URL(url, new URL(basePath, self.location.href)).href;
215  			}});
216  			console.log('Caching', absoluteUrls.length, 'static resources');
217