diff --git a/static/demos/light-dark-demo-4/sw.js b/static/demos/light-dark-demo-4/sw.js index acaf74d..7a54f10 100644 --- a/static/demos/light-dark-demo-4/sw.js +++ b/static/demos/light-dark-demo-4/sw.js @@ -1,18 +1,17 @@ // Cannot use Set-Cookie header for security reasons, use IndexedDB instead self.addEventListener("fetch", event =>{ - + const url = new URL(event.request.url); + if(url.pathname.endsWith(".css")) return; //TODO: make an endpoint to set the localStorage up then set the form to go to there and have it HTTP 302 or 307 with handle_html for html responses and handle_redirect for the other case event.respondWith((async ()=>{ const resp = await fetch(event.request); const resp2 = resp.clone(); const resp3 = resp2.clone(); const body = await resp2.text(); - const url = new URL(event.request.url); if(url.pathname.endsWith("light-dark-toggle")){ return await handle_redirect(event.request); } - else if(url.hostname !== "pagwin.xyz") return; else { return await handle_html(event.request, resp3, body); }