Fix for videos with double quotes in the title
This commit is contained in:
parent
e352cca4d8
commit
e2514185e8
|
@ -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…
Reference in New Issue