From 202b6e06f13da307e0bf0219e9229f4d130967de Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Fri, 19 Nov 2021 13:57:41 +0100 Subject: [PATCH] Fix false negative with linebreaks inside the svg tag --- index.js | 2 +- test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e662321..7a610f4 100644 --- a/index.js +++ b/index.js @@ -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; diff --git a/test.js b/test.js index 7a53d27..3cca99e 100644 --- a/test.js +++ b/test.js @@ -20,6 +20,13 @@ test('valid SVGs', t => { `)); + t.true(isSvg(` +`)); }); test('invalid SVGs', t => {