From 60d6f8921a9db63185f89de7b89d1d02c0bf8bab Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 31 Mar 2015 15:13:11 +0200 Subject: [PATCH] handle node and link IDs with special characters --- lib/router.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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 }