diff options
author | Adam Hovorka <[email protected]> | 2020-04-26 15:40:35 -0600 |
---|---|---|
committer | Adam Hovorka <[email protected]> | 2020-04-26 15:40:35 -0600 |
commit | b2310b38a14ef15e790dc3d25659981a2e08b205 (patch) | |
tree | 14ff452e15223a2beb86e0142eab51da8cc557c3 /main.js | |
parent | 06478d0c8a98eaeb1ddc431943634361ca251e75 (diff) |
Allow visiting pages directly via their ID
Diffstat (limited to 'main.js')
-rw-r--r-- | main.js | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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++) { |