Skip to content

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

Open
asp55 wants to merge 1 commit intopiqnt:masterfrom
asp55:master
Open

Replace split(/\s+/) to allow for spaces in file names & paths when using datafile #91
asp55 wants to merge 1 commit intopiqnt:masterfrom
asp55:master

Conversation

@asp55
Copy link
Copy Markdown

@asp55 asp55 commented Dec 11, 2020

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

…eplace(/"([^"]+)"|'([^']+)'/g,"$1$2"))` to split only on spaces not wrapped in quotes to allow for spaces in file names & paths
@shakiba
Copy link
Copy Markdown
Collaborator

shakiba commented Dec 11, 2020

Thanks, could we use a library instead?

@asp55
Copy link
Copy Markdown
Author

asp55 commented Dec 18, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants