cidr-regex 3.1.1 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.js +6 -9
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ Only match an exact string. Useful with `RegExp#test()` to check if a string is
|
|
|
53
53
|
- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation
|
|
54
54
|
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
|
|
55
55
|
- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
|
|
56
|
+
- [cidr-tools](https://github.com/silverwind/cidr-tools) - Tools to work with IPv4 and IPv6 CIDR network lists
|
|
56
57
|
|
|
57
58
|
## License
|
|
58
59
|
|
package/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const ipRegex = require("ip-regex");
|
|
1
|
+
import ipRegex from "ip-regex";
|
|
4
2
|
|
|
5
3
|
const defaultOpts = {exact: false};
|
|
6
|
-
|
|
7
4
|
const v4str = `${ipRegex.v4().source}\\/(3[0-2]|[12]?[0-9])`;
|
|
8
5
|
const v6str = `${ipRegex.v6().source}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`;
|
|
9
6
|
|
|
10
|
-
//
|
|
11
|
-
// which would require the user to reset .lastIndex on subsequent calls
|
|
7
|
+
// pre-compile only the exact regexes as global flag makes regex objects stateful
|
|
12
8
|
const v4exact = new RegExp(`^${v4str}$`);
|
|
13
9
|
const v6exact = new RegExp(`^${v6str}$`);
|
|
14
10
|
const v46exact = new RegExp(`(?:^${v4str}$)|(?:^${v6str}$)`);
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const cidrRegex = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g");
|
|
13
|
+
export const v4 = cidrRegex.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g");
|
|
14
|
+
export const v6 = cidrRegex.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g");
|
|
15
|
+
export default cidrRegex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cidr-regex",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Regular expression for matching IP addresses in CIDR notation",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"contributors": [
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
],
|
|
9
9
|
"repository": "silverwind/cidr-regex",
|
|
10
10
|
"license": "BSD-2-Clause",
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./index.js",
|
|
13
|
+
"sideEffects": false,
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
15
|
+
"node": ">=14"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"index.js",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"ip address"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"ip-regex": "^
|
|
32
|
+
"ip-regex": "^5.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"eslint": "
|
|
36
|
-
"eslint-config-silverwind": "
|
|
37
|
-
"jest": "
|
|
38
|
-
"tsd": "0.
|
|
39
|
-
"updates": "
|
|
40
|
-
"versions": "
|
|
35
|
+
"eslint": "8.23.1",
|
|
36
|
+
"eslint-config-silverwind": "54.0.2",
|
|
37
|
+
"jest": "29.0.3",
|
|
38
|
+
"tsd": "0.24.1",
|
|
39
|
+
"updates": "13.1.5",
|
|
40
|
+
"versions": "9.3.0"
|
|
41
41
|
}
|
|
42
42
|
}
|