svgexport
svgexport copied to clipboard
Replace `split(/\s+/)` to allow for spaces in file names & paths when using datafile
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
Thanks, could we use a library instead?
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