Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

asp55
Copy link

@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
Collaborator

shakiba commented Dec 11, 2020

Thanks, could we use a library instead?

@asp55
Copy link
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.

None yet

2 participants