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

SyntaxError: invalid regexp group (in Firefox) #24

Closed
vitalets opened this issue Jul 27, 2018 · 5 comments
Closed

SyntaxError: invalid regexp group (in Firefox) #24

vitalets opened this issue Jul 27, 2018 · 5 comments

Comments

@vitalets
Copy link

vitalets commented Jul 27, 2018

https://codepen.io/anon/pen/MBEPWv

ipRegex({exact: false}).exec('2a02:6b8::40c:f145:e87:a3d:abf5');

In Chrome 66 works:

"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 YaBrowser/18.6.1.768 Yowser/2.5 Safari/537.36"
["2a02:6b8::40c:f145:e87:a3d:abf5", "2a02:6b8::40c:f145:e87:a3d:abf5", ...]

In Firefox 61 does not:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0
SyntaxError: invalid regexp group

Seems to be related with: https://bugzilla.mozilla.org/show_bug.cgi?id=1425763

@sindresorhus
Copy link
Owner

This module mainly targets Node.js, not the browser. It's up to you to transpile it with Babel if you want to use it in the browser. You can find a more detailed explanation here: sindresorhus/ama#446

If you use Webpack, check out babel-engine-plugin, which transpiles only the dependencies that needs to be transpiled.

@vitalets
Copy link
Author

hi @sindresorhus, this is not transpiling issue.
To reproduce you can just evaluate in Firefox console these lines from index.js:

const word = '[a-fA-F\\d:]';
const b = `(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))`;
new RegExp(b);

> SyntaxError: invalid regexp group

I assume the bug related to different js engines used in Chrome/Firefox and particularly how they handle regexp.

@sindresorhus
Copy link
Owner

Lookbehind regex syntax (which this module uses) is not supported in Firefox. This module targets Node.js and V8, so this is not a concern for me.

@vitalets
Copy link
Author

Now that is clear, thanks.

@karlcow
Copy link

karlcow commented Oct 2, 2019

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

No branches or pull requests

3 participants