cidr-regex 5.0.3 → 5.0.4
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 +23 -12
- package/dist/index.js +6 -7
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
+
//#region index.d.ts
|
|
1
2
|
type CidrRegexOptions = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly exact?: boolean;
|
|
3
|
+
/**
|
|
4
|
+
Only match an exact string. Useful with `RegExp#test()` to check if a string is an IP address. *(`false` matches any IP address in a string)*
|
|
5
|
+
@defaultValue false
|
|
6
|
+
*/
|
|
7
|
+
readonly exact?: boolean;
|
|
8
8
|
};
|
|
9
9
|
declare const cidrRegex: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
({
|
|
11
|
+
exact
|
|
12
|
+
}?: CidrRegexOptions): RegExp;
|
|
13
|
+
v4: ({
|
|
14
|
+
exact
|
|
15
|
+
}?: CidrRegexOptions) => RegExp;
|
|
16
|
+
v6: ({
|
|
17
|
+
exact
|
|
18
|
+
}?: CidrRegexOptions) => RegExp;
|
|
13
19
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
declare const v4: ({
|
|
21
|
+
exact
|
|
22
|
+
}?: CidrRegexOptions) => RegExp;
|
|
23
|
+
declare const v6: ({
|
|
24
|
+
exact
|
|
25
|
+
}?: CidrRegexOptions) => RegExp;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { cidrRegex as default, v4, v6 };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region index.ts
|
|
1
2
|
const defaultOpts = { exact: false };
|
|
2
3
|
const v4src = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1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[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|:(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:))(?:%[0-9a-zA-Z]+)?\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])";
|
|
@@ -9,14 +10,12 @@ const v4global = new RegExp(v4src, "g");
|
|
|
9
10
|
const v6global = new RegExp(v6src, "g");
|
|
10
11
|
const v46global = new RegExp(v46src, "g");
|
|
11
12
|
function resetRegex(re) {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
re.lastIndex = 0;
|
|
14
|
+
return re;
|
|
14
15
|
}
|
|
15
16
|
const cidrRegex = ({ exact } = defaultOpts) => exact ? v46exact : resetRegex(v46global);
|
|
16
17
|
const v4 = cidrRegex.v4 = ({ exact } = defaultOpts) => exact ? v4exact : resetRegex(v4global);
|
|
17
18
|
const v6 = cidrRegex.v6 = ({ exact } = defaultOpts) => exact ? v6exact : resetRegex(v6global);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
v6
|
|
22
|
-
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { cidrRegex as default, v4, v6 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cidr-regex",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Regular expression for matching IP addresses in CIDR notation",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"contributors": [
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "25.0
|
|
24
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
25
|
-
"eslint": "
|
|
26
|
-
"eslint-config-silverwind": "
|
|
23
|
+
"@types/node": "25.6.0",
|
|
24
|
+
"@typescript/native-preview": "7.0.0-dev.20260420.1",
|
|
25
|
+
"eslint": "10.2.1",
|
|
26
|
+
"eslint-config-silverwind": "131.0.5",
|
|
27
27
|
"jest-extended": "7.0.0",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"vitest": "4.
|
|
36
|
-
"vitest-config-silverwind": "
|
|
28
|
+
"tsdown": "0.21.9",
|
|
29
|
+
"tsdown-config-silverwind": "2.1.0",
|
|
30
|
+
"typescript": "6.0.3",
|
|
31
|
+
"typescript-config-silverwind": "18.0.0",
|
|
32
|
+
"updates": "17.15.5",
|
|
33
|
+
"updates-config-silverwind": "2.1.0",
|
|
34
|
+
"versions": "15.0.0",
|
|
35
|
+
"vitest": "4.1.4",
|
|
36
|
+
"vitest-config-silverwind": "11.3.0"
|
|
37
37
|
}
|
|
38
38
|
}
|