Skip to content

Commit

Permalink
refactor(cleanupNumbericValues): improve how viewbox is split
Browse files Browse the repository at this point in the history
Co-authored-by: GreLI <[email protected]>
  • Loading branch information
SethFalco and GreLI committed Jun 30, 2024
1 parent b8f8d1c commit 52d6750
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/cleanupNumericValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ export const fn = (_root, params) => {
element: {
enter: (node) => {
if (node.attributes.viewBox != null) {
const nums = node.attributes.viewBox.split(/\s,?\s*|,\s*/g);
const nums = node.attributes.viewBox.split(
/\b(?:\s+,?|\s*,)\s*(?=\S)/g,
);
node.attributes.viewBox = nums
.filter((value) => value.length != 0)
.map((value) => {
const num = Number(value);
return Number.isNaN(num)
Expand Down

0 comments on commit 52d6750

Please sign in to comment.