diff --git a/lib/router.js b/lib/router.js index ac5555f..2bc38f5 100644 --- a/lib/router.js +++ b/lib/router.js @@ -9,10 +9,10 @@ define(function () { if (d) { if ("node" in d) - s += "n:" + d.node.nodeinfo.node_id + s += "n:" + encodeURIComponent(d.node.nodeinfo.node_id) if ("link" in d) - s += "l:" + linkId(d.link) + s += "l:" + encodeURIComponent(linkId(d.link)) } window.history.pushState(s, undefined, s) @@ -51,19 +51,15 @@ define(function () { var args = s.slice(2).split(":") var id - if (args[0] === "n") { - id = args[1] + if (args[1] !== undefined) { + id = decodeURIComponent(args[1]) - if (id in objects.nodes) { + if (args[0] === "n" && id in objects.nodes) { gotoNode(objects.nodes[id]) return true } - } - if (args[0] === "l") { - id = args[1] - - if (id in objects.links) { + if (args[0] === "l" && id in objects.links) { gotoLink(objects.links[id]) return true }