SyntaxError: invalid regexp group (in Firefox)
vitalets opened this issue · 5 comments
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
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.
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.
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.
Now that is clear, thanks.