diff --git a/static/demos/light-dark-demo-4/index.html b/static/demos/light-dark-demo-4/index.html index 42cc164..5297d75 100644 --- a/static/demos/light-dark-demo-4/index.html +++ b/static/demos/light-dark-demo-4/index.html @@ -76,7 +76,7 @@ -

Don't copy this code at all, it is for demo purposes only and is terrible code. Note: if you +

Don't copy this code at all, it is for demo purposes only and is terrible code.
Note: if + you hard refresh you will get your system preference of light/dark due to this demo being powered by a service worker

+
+
diff --git a/static/demos/light-dark-demo-4/sw.js b/static/demos/light-dark-demo-4/sw.js index c4960f5..3fd6276 100644 --- a/static/demos/light-dark-demo-4/sw.js +++ b/static/demos/light-dark-demo-4/sw.js @@ -19,9 +19,9 @@ self.addEventListener("fetch", event =>{ }) async function handle_redirect(req){ - const go_back_to = req.headers.get('Referer') || '/';; - console.log("ref:",req.headers.get('Referer'), go_back_to); - console.log('All headers:', [...req.headers.entries()]); + const url = new URL(event.request.url); + const go_back_to = url.searchParams.get('ref') ?? '/'; + console.log("ref:",url.searchParams.get('ref'), go_back_to); const db_req = self.indexedDB.open("light-dark-store");