Skip to content

Commit

Permalink
Fix broken SVG check (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
localnerve authored Jun 15, 2024
1 parent 246ff6f commit 0c37309
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ const imageminSvgo = options => async buffer => {
...options,
};

if (!isSvg(buffer)) {
return buffer;
}
const normalizedInput = Buffer.isBuffer(buffer) ? buffer.toString() : buffer;

if (Buffer.isBuffer(buffer)) {
buffer = buffer.toString();
if (!isSvg(normalizedInput)) {
return buffer;
}

const {data} = optimize(buffer, options);
const {data} = optimize(normalizedInput, options);
return Buffer.from(data);
};

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"svgo"
],
"dependencies": {
"is-svg": "^5.0.0",
"svgo": "^3.2.0"
"is-svg": "^5.0.1",
"svgo": "^3.3.2"
},
"devDependencies": {
"ava": "^6.1.2",
"ava": "^6.1.3",
"xo": "^0.58.0"
}
}

0 comments on commit 0c37309

Please sign in to comment.