We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents fc0028a + 2e1194b commit da47839Copy full SHA for da47839
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,15 @@
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
+ const RE2 = require('re2');
8
+ return typeof RE2 === 'function' ? RE2 : RegExp;
9
+ } catch {
10
+ return RegExp;
11
+ }
12
+})();
13
const ipv4 = ipRegex.v4().source;
14
const ipv6 = ipRegex.v6().source;
15
0 commit comments