svgexport icon indicating copy to clipboard operation
svgexport copied to clipboard

Replace `split(/\s+/)` to allow for spaces in file names & paths when using datafile

Open asp55 opened this issue 4 years ago • 2 comments

Replace split(/\s+/) with match(/\w+|"[^"]+"|'[^']+'/g).map(v=>v.replace(/"([^"]+)"|'([^']+)'/g,"$1$2")) to split only on spaces not wrapped in quotes to allow for spaces in file names & paths

asp55 avatar Dec 11 '20 23:12 asp55

Thanks, could we use a library instead?

shakiba avatar Dec 11 '20 23:12 shakiba

Not sure I follow what you'd be using a library to do.

The existing use of split(/\s+/) in splitParams function makes it so that if you're using a datafile to do your configuration and you have a space in a file path, it'll split that as well.

In the replacement line: match(/\w+|"[^"]+"|'[^']+'/g) splits only on spaces that aren't wrapped in quotes. And then the map(v=>v.replace(/"([^"]+)"|'([^']+)'/g,"$1$2")) removes those wrapping quotes

asp55 avatar Dec 18 '20 01:12 asp55