aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hovorka <[email protected]>2020-04-26 15:40:35 -0600
committerAdam Hovorka <[email protected]>2020-04-26 15:40:35 -0600
commitb2310b38a14ef15e790dc3d25659981a2e08b205 (patch)
tree14ff452e15223a2beb86e0142eab51da8cc557c3
parent06478d0c8a98eaeb1ddc431943634361ca251e75 (diff)
Allow visiting pages directly via their ID
-rw-r--r--main.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/main.js b/main.js
index 741e39c..7b8f761 100644
--- a/main.js
+++ b/main.js
@@ -136,14 +136,19 @@ function resizeTA(e) {
}
function renderPath() {
- let path = location.hash.slice(2);
+ let path = location.hash.slice(1);
const main = document.getElementById("main");
const o = main.cloneNode(false);
state.addcount = 0;
+ if (!path.startsWith("/")) {
+ if (/^[0-9]+$/.test(path) && data.pages[+path] &&
+ data.pages[+path].paths[0]) path = data.pages[+path].paths[0];
+ else path = "";
+ } else path = path.slice(1);
state.editing = path.endsWith("edit");
if (state.editing) path = path.slice(0,-5);
- if (!/[0-9]+(-[0-9]+)*/.test(path)) path = "";
+ if (!/^[0-9]+(-[0-9]+)*$/.test(path)) path = "";
const pieces = path.split("-");
if (pieces[0]) for (let i=0; i<pieces.length; i++) {