mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 16:18:11 -05:00
✨ Add path parser js impl more resilent to parse errors
This commit is contained in:
parent
36b5ca7313
commit
77472aabea
1 changed files with 15 additions and 5 deletions
|
@ -916,11 +916,21 @@ function simplifyPathData(pdata) {
|
|||
export function parse(string) {
|
||||
if (!string || string.length === 0) return [];
|
||||
|
||||
var source = new Parser(string);
|
||||
var result = Array.from(source);
|
||||
try {
|
||||
var source = new Parser(string);
|
||||
var result = Array.from(source);
|
||||
|
||||
result = absolutizePathData(result);
|
||||
result = simplifyPathData(result);
|
||||
result = absolutizePathData(result);
|
||||
result = simplifyPathData(result);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
} catch (cause) {
|
||||
const msg = "unexpected exception parsing path";
|
||||
console.group(msg);
|
||||
console.log(`string: ${string}`)
|
||||
console.error(cause);
|
||||
console.groupEnd(msg);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue