-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Fix path regex match bug #3686
Conversation
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! |
How about using https://www.npmjs.com/package/escape-string-regexp? |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@Timer thanks. I modified the code to use the package |
Great, thanks much! |
This is out in |
* 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
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 anInvalid 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
Changing the path for the project solved the problem.