diff options
-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++) { |