From 5836f53a243bc6766d283e5af0f021b71cf4c3bd Mon Sep 17 00:00:00 2001 From: adrien Date: Sat, 14 Nov 2020 12:45:49 +0100 Subject: [PATCH] manage url args --- nginx-example.conf | 2 +- sudoku.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nginx-example.conf b/nginx-example.conf index 23cfcb8..d665aad 100644 --- a/nginx-example.conf +++ b/nginx-example.conf @@ -25,5 +25,5 @@ location /sudoku/ { } location ~ "^/sudoku/([1-9.]{81})$" { - rewrite "^/sudoku/([1-9.]{81})$" /sudoku/sudoku.php?grid=$1 last; + rewrite "^/sudoku/([1-9.]{81})\??(.*)?(#.*)?$" /sudoku/sudoku.php?grid=$1&$2$3 last; } diff --git a/sudoku.js b/sudoku.js index 5813052..51f11b0 100644 --- a/sudoku.js +++ b/sudoku.js @@ -52,7 +52,7 @@ window.onload = function () { rowId++ } - const savedGame = localStorage[location.href] + const savedGame = localStorage[location.pathname] if (savedGame) { boxes.forEach((box, i) => { if (!box.disabled && savedGame[i] != UNKNOWN) { @@ -79,7 +79,7 @@ window.onload = function () { refreshUI() if ("serviceWorker" in navigator) { - navigator.serviceWorker.register(`service-worker.php?location=${location.href}`) + navigator.serviceWorker.register(`service-worker.php?location=${location.pathname}`) } } @@ -150,7 +150,7 @@ function oninput() { function refreshBox(box) { let saveGame = boxes.map(box => box.value || UNKNOWN).join("") - localStorage[location.href] = saveGame + localStorage[location.pathname] = saveGame fixGridLink.href = saveGame box.neighbourhood.concat([box]).forEach(neighbour => {