Skip to content

Commit

Permalink
Fix false-negative with linebreaks inside the SVG tag (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanHoyer authored Nov 24, 2021
1 parent 034967d commit d46292d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const isSvg = input => {
return false;
}

input = input.toString().trim();
input = input.toString().trim().replace(/\n/g, ' ');

if (input.length === 0) {
return false;
Expand Down
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ test('valid SVGs', t => {
<svg version="1.1">
</svg>
`));
t.true(isSvg(`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg"
width="75"
height="75"
version="1.1"
></svg>`));
});

test('invalid SVGs', t => {
Expand Down

0 comments on commit d46292d

Please sign in to comment.