Skip to content

Commit 1c0bbda

Browse files
committed
[fix] Setting : instead of - causing issues on uuid
1 parent 463ed3b commit 1c0bbda

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/js/netjsongraph.util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ class NetJSONGraphUtil {
12611261
nodeData = self.data.nodes[index];
12621262
} else if (params.dataType === "edge") {
12631263
const {source, target} = params.data;
1264-
nodeId = `${source}-${target}`;
1264+
nodeId = `${source}:${target}`;
12651265
index = self.nodeIndex[source];
12661266
nodeData = self.data.links[index];
12671267
}
@@ -1272,7 +1272,7 @@ class NetJSONGraphUtil {
12721272
nodeData = self.data.nodes[index];
12731273
} else if (params.seriesType === "lines") {
12741274
const {source, target} = params.data.link;
1275-
nodeId = `${source}-${target}`;
1275+
nodeId = `${source}:${target}`;
12761276
index = self.nodeIndex[source];
12771277
nodeData = self.data.links[index];
12781278
}
@@ -1306,7 +1306,7 @@ class NetJSONGraphUtil {
13061306
if (!nodeId || !self.nodeIndex || !self.nodeIndex[nodeId] == null) {
13071307
return;
13081308
}
1309-
const [source, target] = nodeId.split("-");
1309+
const [source, target] = nodeId.split(":");
13101310
const index = self.nodeIndex[nodeId];
13111311
// If source && target both exists then the node is a link
13121312
const node = source && target ? self.data.links[index] : self.data.nodes[index];

test/netjsongraph.util.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ describe("Test URL fragment utilities", () => {
203203

204204
test("Test parseUrlFragments parses multiple fragments and decodes values", () => {
205205
window.location.hash =
206-
"#id=geoMap&nodeId=abc%3A123;id=indoorMap&nodeId=indoor-node";
206+
"#id=geoMap&nodeId=abc%3A123;id=indoorMap&nodeId=indoorNode";
207207
const fragments = utils.parseUrlFragments();
208208

209209
expect(Object.keys(fragments).sort()).toEqual(["geoMap", "indoorMap"].sort());
210210
expect(fragments.geoMap.get("nodeId")).toBe("abc:123");
211-
expect(fragments.indoorMap.get("nodeId")).toBe("indoor-node");
211+
expect(fragments.indoorMap.get("nodeId")).toBe("indoorNode");
212212
});
213213

214214
test("Test addActionToUrl adds a new fragment with nodeId for a node", () => {
@@ -244,7 +244,7 @@ describe("Test URL fragment utilities", () => {
244244
},
245245
data: {links: [link]},
246246
utils: {...utils, graphRender: "graph", mapRender: "map"},
247-
nodeIndex: {"node1-node2": 0},
247+
nodeIndex: {"node1:node2": 0},
248248
};
249249

250250
const params = {
@@ -257,7 +257,7 @@ describe("Test URL fragment utilities", () => {
257257
const fragments = utils.parseUrlFragments();
258258
expect(fragments.basicUsage).toBeDefined();
259259
expect(fragments.basicUsage.get("id")).toBe("basicUsage");
260-
expect(fragments.basicUsage.get("nodeId")).toBe("node1-node2");
260+
expect(fragments.basicUsage.get("nodeId")).toBe("node1:node2");
261261
});
262262

263263
test("Test addActionToUrl updates an existing fragment and preserves others", () => {
@@ -345,12 +345,12 @@ describe("Test URL fragment utilities", () => {
345345
onClickElement: mockOnClick,
346346
},
347347
data: {links: [link]},
348-
nodeIndex: {"n1-n2": 0},
348+
nodeIndex: {"n1:n2": 0},
349349
leaflet: {setView: mockSetView, getZoom: () => 6},
350350
utils,
351351
};
352352

353-
window.location.hash = "#id=geo&nodeId=n1-n2";
353+
window.location.hash = "#id=geo&nodeId=n1:n2";
354354

355355
utils.applyUrlFragmentState(self);
356356

0 commit comments

Comments
 (0)