handle node and link IDs with special characters

This commit is contained in:
Nils Schneider 2015-03-31 15:13:11 +02:00
parent af3d22e4c2
commit 60d6f8921a

View file

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