Browse Source

Fix for videos with double quotes in the title

master
Mattéo Delabre 2 years ago
parent
commit
e2514185e8
Signed by: matteo GPG Key ID: AE3FBD02DC583ABB
  1. 9
      explore/graph.mjs

9
explore/graph.mjs

@ -6,6 +6,11 @@ const GRAPH_NODE = ' "%s" [label="%s"]';
const GRAPH_NODE_URL = ' "%s" [label="%s", URL="%s", fontcolor=blue]';
const GRAPH_LINK = ' "%s" -> "%s"';
/**
* Escape double quotes in a string.
*/
const escapeQuotes = str => str.replace(/"/g, '\\"');
/**
* Convert a graph to the DOT format.
*
@ -27,11 +32,11 @@ export const graphToDOT = (graph, title = id => id, url = () => '') =>
if (url === '')
{
return util.format(GRAPH_NODE, id, nodeTitle);
return util.format(GRAPH_NODE, id, escapeQuotes(nodeTitle));
}
else
{
return util.format(GRAPH_NODE_URL, id, nodeTitle, nodeUrl);
return util.format(GRAPH_NODE_URL, id, escapeQuotes(nodeTitle), nodeUrl);
}
}
).join('\n');

Loading…
Cancel
Save