1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

fix: don't insert 0 at start or end of attribute if whitespace (#2036)

This commit is contained in:
Seth Falco
2024-06-14 12:48:56 +01:00
committed by GitHub
parent e73d13a1a5
commit 5481fc2477
3 changed files with 8 additions and 2 deletions

View File

@ -39,6 +39,7 @@ export const fn = (_root, params) => {
if (node.attributes.viewBox != null) {
const nums = node.attributes.viewBox.split(/\s,?\s*|,\s*/g);
node.attributes.viewBox = nums
.filter((value) => value.length != 0)
.map((value) => {
const num = Number(value);
return Number.isNaN(num)
@ -54,7 +55,7 @@ export const fn = (_root, params) => {
continue;
}
const match = value.match(regNumericValues);
const match = regNumericValues.exec(value);
// if attribute value matches regNumericValues
if (match) {