cidr-regex 6.0.0 → 7.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/dist/index.d.ts +1 -1
- package/dist/index.js +13 -10
- package/package.json +16 -13
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
//#region index.ts
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const octet = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)";
|
|
3
|
+
const v4dotted = `${octet}(?:\\.${octet}){3}`;
|
|
4
|
+
const hex = "[\\dA-Fa-f]{1,4}";
|
|
5
|
+
const scopeIdRe = "(?:%[^\\s%/\\0]+)?";
|
|
6
|
+
const v4src = `${v4dotted}/(?:3[0-2]|[12]?\\d)`;
|
|
7
|
+
const v6src = `(?:(?:${hex}:){7}(?:${hex}|:)|(?:${hex}:){6}(?:${v4dotted}|:${hex}|:)|(?:${hex}:){5}(?::${v4dotted}|(?::${hex}){1,2}|:)|(?:${hex}:){4}(?:(?::${hex})?:${v4dotted}|(?::${hex}){1,3}|:)|(?:${hex}:){3}(?:(?::${hex}){0,2}:${v4dotted}|(?::${hex}){1,4}|:)|(?:${hex}:){2}(?:(?::${hex}){0,3}:${v4dotted}|(?::${hex}){1,5}|:)|${hex}:(?:(?::${hex}){0,4}:${v4dotted}|(?::${hex}){1,6}|:)|:(?:(?::${hex}){0,5}:${v4dotted}|(?::${hex}){1,7}|:))${scopeIdRe}/(?:12[0-8]|1[01]\\d|[1-9]?\\d)`;
|
|
8
|
+
const v6srcFast = `(?=[\\dA-Fa-f:])${v6src}`;
|
|
6
9
|
const v4exact = new RegExp(`^${v4src}$`);
|
|
7
10
|
const v6exact = new RegExp(`^${v6src}$`);
|
|
8
|
-
const v46exact = new RegExp(
|
|
11
|
+
const v46exact = new RegExp(`^(?:${v4src}|${v6src})$`);
|
|
9
12
|
const v4global = new RegExp(v4src, "g");
|
|
10
|
-
const v6global = new RegExp(
|
|
11
|
-
const v46global = new RegExp(
|
|
13
|
+
const v6global = new RegExp(v6srcFast, "g");
|
|
14
|
+
const v46global = new RegExp(`${v4src}|${v6srcFast}`, "g");
|
|
12
15
|
function resetRegex(re) {
|
|
13
16
|
re.lastIndex = 0;
|
|
14
17
|
return re;
|
|
15
18
|
}
|
|
16
|
-
const cidrRegex = ({ exact } =
|
|
17
|
-
const v4 = cidrRegex.v4 = ({ exact } =
|
|
18
|
-
const v6 = cidrRegex.v6 = ({ exact } =
|
|
19
|
+
const cidrRegex = ({ exact } = {}) => exact ? v46exact : resetRegex(v46global);
|
|
20
|
+
const v4 = cidrRegex.v4 = ({ exact } = {}) => exact ? v4exact : resetRegex(v4global);
|
|
21
|
+
const v6 = cidrRegex.v6 = ({ exact } = {}) => exact ? v6exact : resetRegex(v6global);
|
|
19
22
|
|
|
20
23
|
//#endregion
|
|
21
24
|
export { cidrRegex as default, v4, v6 };
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cidr-regex",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Regular expression for matching IP addresses in CIDR notation",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"
|
|
8
8
|
],
|
|
9
|
-
"repository":
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "silverwind/cidr-regex"
|
|
12
|
+
},
|
|
10
13
|
"keywords": [
|
|
11
14
|
"cidr",
|
|
12
15
|
"regex",
|
|
@@ -33,19 +36,19 @@
|
|
|
33
36
|
"node": ">=22"
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
|
-
"@types/node": "25.
|
|
37
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
38
|
-
"eslint": "10.
|
|
39
|
-
"eslint-config-silverwind": "
|
|
39
|
+
"@types/node": "25.7.0",
|
|
40
|
+
"@typescript/native-preview": "7.0.0-dev.20260512.1",
|
|
41
|
+
"eslint": "10.3.0",
|
|
42
|
+
"eslint-config-silverwind": "133.0.1",
|
|
40
43
|
"jest-extended": "7.0.0",
|
|
41
|
-
"tsdown": "0.
|
|
42
|
-
"tsdown-config-silverwind": "3.0.
|
|
44
|
+
"tsdown": "0.22.0",
|
|
45
|
+
"tsdown-config-silverwind": "3.0.1",
|
|
43
46
|
"typescript": "6.0.3",
|
|
44
47
|
"typescript-config-silverwind": "18.0.0",
|
|
45
|
-
"updates": "17.16.
|
|
46
|
-
"updates-config-silverwind": "
|
|
47
|
-
"versions": "15.0.
|
|
48
|
-
"vitest": "4.1.
|
|
49
|
-
"vitest-config-silverwind": "11.3.
|
|
48
|
+
"updates": "17.16.10",
|
|
49
|
+
"updates-config-silverwind": "4.0.0",
|
|
50
|
+
"versions": "15.0.3",
|
|
51
|
+
"vitest": "4.1.6",
|
|
52
|
+
"vitest-config-silverwind": "11.3.4"
|
|
50
53
|
}
|
|
51
54
|
}
|