-
-
Notifications
You must be signed in to change notification settings - Fork 9
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 regexp without flags throwing SyntaxError #3
Conversation
I also added one commit to cast the regex to string, because |
Thanks for the PR!
Understandable. However, they are two different values.
const regex = /foo/;
console.log(regex.source); //=> 'foo'
console.log(regex.toString()); //=> '/foo/' I'd prefer that the PR be isolated and focused on the problem being solved. Would it be too much trouble for you to revert the change to |
Hello, I think you misread the PR by looking at it as a whole. There are two separate commits here:
I can open separate PRs if you want but I thought that 2 commits in one PR was sufficient :) |
Yes, See the slashes? Here is what happens when you use the value returned by // the regular expression is incorrect, as we do not want the leading and trailing slashes added to the string.
console.log(new RegExp(regex.toString())) //=> /\/foo\// Again, do you see the slashes? We don't want the slashes.
|
Once again, I didn't change But anyway, I dropped that commit, since it's not important -- can you check if it's ok now? |
@jonschlinkert running into the SyntaxError as well using |
It seems that
RegExp
constructor doesn't like the 2nd param to benull
, but it can beundefined