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

Fix path regex match bug #3686

Merged
merged 4 commits into from
Jan 4, 2018
Merged

Fix path regex match bug #3686

merged 4 commits into from
Jan 4, 2018

Conversation

Norris1z
Copy link
Contributor

@Norris1z Norris1z commented Jan 4, 2018

This change prevents Regex expression errors from being thrown when the paths passed to the function has a ++ in them.

Taking a path like some/dummy/path/with++/
the function transforms it to some\/dummy\/path\/with++\/ the second + is not ignored by the regex engine and hence throws an Invalid Regular Expression Error

This pull request changes the path to some\/dummy\/path\/with\+\+\/ with all + escaped.

I noticed the bug when i tried to run npm start in a directory containing a + in it's name.
npm version 5.5.1
node version 8.9.3

$ npm start

> [email protected] start C:\Users\Norris\Desktop\C_C++\JS\NodeJs\demoreact
> react-scripts start

Invalid regular expression: /^(?!C:\\Users\\Norris\\Desktop\\C_C++\\JS\\NodeJs\\demoreact\\src\\).+[\\/]node_modules[\\/]/: Nothing to repeat
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Changing the path for the project solved the problem.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@Timer
Copy link
Contributor

Timer commented Jan 4, 2018

How about using https://www.npmjs.com/package/escape-string-regexp?

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@Norris1z
Copy link
Contributor Author

Norris1z commented Jan 4, 2018

@Timer thanks. I modified the code to use the package

@Timer
Copy link
Contributor

Timer commented Jan 4, 2018

Great, thanks much!

@Timer Timer added this to the 1.0.18 milestone Jan 4, 2018
@Timer Timer merged commit 8cae659 into facebook:master Jan 4, 2018
@gaearon gaearon mentioned this pull request Jan 15, 2018
@gaearon
Copy link
Contributor

gaearon commented Jan 15, 2018

This is out in [email protected]! Please let us know if something doesn’t quite work.
https://github.com/facebookincubator/create-react-app/releases/tag/v1.1.0

Pavek pushed a commit to Pavek/create-react-app that referenced this pull request Jul 10, 2018
* Fix path regex match bug

* Use the escape-string-regexp package to escape regex characters

* Remove redundant character escape from path

* Add removed escape of backslashes
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants