We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fc0028a commit a418940Copy full SHA for a418940
package.json
@@ -17,7 +17,7 @@
17
],
18
"dependencies": {
19
"ip-regex": "^4.3.0",
20
- "re2": "^1.15.9",
+ "re2": "^1.16.0",
21
"tlds": "^1.217.0"
22
},
23
"devDependencies": {
src/index.js
@@ -1,9 +1,14 @@
1
-const RE2 = require('re2');
2
const ipRegex = require('ip-regex');
3
const tlds = require('tlds');
4
5
/* istanbul ignore next */
6
-const SafeRegExp = typeof RE2 === 'function' ? RE2 : RegExp;
+const SafeRegExp = (() => {
+ try {
7
+ return require('re2');
8
+ } catch {
9
+ return RegExp;
10
+ }
11
+})();
12
const ipv4 = ipRegex.v4().source;
13
const ipv6 = ipRegex.v6().source;
14
0 commit comments