Skip to content

Commit

Permalink
fix: Add SVG path parser null check. (#3451).
Browse files Browse the repository at this point in the history
  • Loading branch information
jheer committed Mar 25, 2022
1 parent 9a3faca commit 3fb45ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vega-scenegraph/src/path/parse.js
Expand Up @@ -6,8 +6,9 @@ const flagPattern = /^[01]/;

export default function parse(path) {
const commands = [];
const matches = path.match(commandPattern) || [];

path.match(commandPattern).forEach(str => {
matches.forEach(str => {
let cmd = str[0];
const type = cmd.toLowerCase();

Expand Down
7 changes: 7 additions & 0 deletions packages/vega-scenegraph/test/path-test.js
Expand Up @@ -111,6 +111,13 @@ tape('pathParse should parse svg path', t => {
t.end();
});

tape('pathParse should handle an empty string', t => {
const s = '';
const p = [];
t.deepEqual(pathParse(s), p);
t.end();
});

tape('pathParse should handle repeated arguments', t => {
const s = 'M 1 1 L 1 2 3 4';
const p = [['M',1,1], ['L',1,2], ['L',3,4]];
Expand Down

0 comments on commit 3fb45ff

Please sign in to comment.