codefeathers / rollup-plugin-svelte-svg

Import SVG files as Svelte Components
MIT License
75 stars 13 forks source link

redundant regexp constructor? #21

Closed pateketrueke closed 3 years ago

pateketrueke commented 3 years ago

Hi, out of curiosity, this line seems odd: https://github.com/codefeathers/rollup-plugin-svelte-svg/blob/50e64b90d820aeadb7326f60124056940607c9ca/src/index.js#L39

I mean, using a new RegExp and passing a regexp as argument is just doing the job twice, e.g.

const re = new RegExp(/(<svg.*?)(>.*)/, "s");
const re2 = /(<svg.*?)(>.*)/s
console.log(re.source === re2.source); // => true

This means you can use re2 directly, without having to use the new RegExp constructor.

MKRhere commented 3 years ago

Sure heh, I was refactoring from using RegExp constructor with string, guessed I'd just use RegExp primitive instead, didn't come back to the constructor while testing. Will fix in the next update. Thanks for chiming in!