Skip to content

Commit

Permalink
Fix false negative with linebreaks inside the svg tag
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanHoyer committed Nov 19, 2021
1 parent 034967d commit 202b6e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
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
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 202b6e0

Please sign in to comment.