diff --git a/lib/extract/extractBrush.js b/lib/extract/extractBrush.js index e7599f0b..c0e6550b 100644 --- a/lib/extract/extractBrush.js +++ b/lib/extract/extractBrush.js @@ -3,7 +3,7 @@ import extractColor from './extractColor'; const urlIdPattern = /^url\(#(.+?)\)$/; export default function extractBrush(colorOrBrush) { - if (colorOrBrush === 'none' || !colorOrBrush) { + if (!colorOrBrush || colorOrBrush === 'none') { return null; } @@ -11,7 +11,7 @@ export default function extractBrush(colorOrBrush) { return [2]; } try { - const matched = colorOrBrush.match(urlIdPattern); + const matched = typeof colorOrBrush === 'string' && colorOrBrush.match(urlIdPattern); // brush if (matched) { return [1, matched[1]]; diff --git a/lib/extract/extractGradient.js b/lib/extract/extractGradient.js index 8415b45e..b2d01ea3 100644 --- a/lib/extract/extractGradient.js +++ b/lib/extract/extractGradient.js @@ -17,7 +17,7 @@ function percentToFloat(percent) { ) { return percent.__getAnimatedValue(); } - const matched = percent.match(percentReg); + const matched = typeof percent === 'string' && percent.match(percentReg); if (!matched) { console.warn(`"${percent}" is not a valid number or percentage string.`); return 0;