cidr-tools 12.1.1 → 12.1.2
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.js +11 -6
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -80,7 +80,7 @@ function doNormalize(cidr, opts) {
|
|
|
80
80
|
const slashIndex = rangeSlashIndex;
|
|
81
81
|
const prefixPresent = slashIndex !== -1;
|
|
82
82
|
let prefixNum = prefixPresent ? parsePrefixNum(cidr, slashIndex) : -1;
|
|
83
|
-
const { number, version } = parseIp(prefixPresent ? cidr.substring(0, slashIndex) : cidr);
|
|
83
|
+
const { number, version, ipv4mapped, scopeid } = parseIp(prefixPresent ? cidr.substring(0, slashIndex) : cidr);
|
|
84
84
|
if (prefixNum === -1) prefixNum = bits[version];
|
|
85
85
|
if (version === 4) {
|
|
86
86
|
const hostBits = 32 - prefixNum;
|
|
@@ -96,10 +96,13 @@ function doNormalize(cidr, opts) {
|
|
|
96
96
|
compress,
|
|
97
97
|
hexify
|
|
98
98
|
});
|
|
99
|
+
const start = hostBits > 0 ? number & hostNotMasks[hostBits] : number;
|
|
99
100
|
const ip = stringifyIp({
|
|
100
|
-
number:
|
|
101
|
-
version
|
|
102
|
-
|
|
101
|
+
number: start,
|
|
102
|
+
version,
|
|
103
|
+
ipv4mapped: ipv4mapped && start >> 32n === 65535n,
|
|
104
|
+
scopeid
|
|
105
|
+
}, { hexify });
|
|
103
106
|
return (compress ? ip : normalizeIp(ip, {
|
|
104
107
|
compress,
|
|
105
108
|
hexify
|
|
@@ -553,7 +556,8 @@ function containsCidr(a, b) {
|
|
|
553
556
|
for (const target of v4b) {
|
|
554
557
|
const ts = target.start, te = target.end;
|
|
555
558
|
let covered = false;
|
|
556
|
-
for (const iv of v4a)
|
|
559
|
+
for (const iv of v4a) {
|
|
560
|
+
if (iv.start > ts || iv.end < te) continue;
|
|
557
561
|
covered = true;
|
|
558
562
|
break;
|
|
559
563
|
}
|
|
@@ -582,7 +586,8 @@ function containsCidr(a, b) {
|
|
|
582
586
|
for (const target of v6b) {
|
|
583
587
|
const ts = target.start, te = target.end;
|
|
584
588
|
let covered = false;
|
|
585
|
-
for (const iv of v6a)
|
|
589
|
+
for (const iv of v6a) {
|
|
590
|
+
if (iv.start > ts || iv.end < te) continue;
|
|
586
591
|
covered = true;
|
|
587
592
|
break;
|
|
588
593
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cidr-tools",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.2",
|
|
4
4
|
"author": "silverwind <me@silverwind.io>",
|
|
5
5
|
"description": "Tools to work with IPv4 and IPv6 CIDR",
|
|
6
6
|
"keywords": [
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"ip-bigint": "^9.0.6"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "
|
|
36
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
35
|
+
"@types/node": "26.0.1",
|
|
36
|
+
"@typescript/native-preview": "7.0.0-dev.20260627.2",
|
|
37
37
|
"@vitest/coverage-v8": "4.1.9",
|
|
38
|
-
"eslint": "10.
|
|
39
|
-
"eslint-config-silverwind": "
|
|
38
|
+
"eslint": "10.6.0",
|
|
39
|
+
"eslint-config-silverwind": "138.0.0",
|
|
40
40
|
"jest-extended": "7.0.0",
|
|
41
41
|
"tsdown": "0.22.3",
|
|
42
|
-
"tsdown-config-silverwind": "3.0.
|
|
42
|
+
"tsdown-config-silverwind": "3.0.4",
|
|
43
43
|
"typescript": "6.0.3",
|
|
44
44
|
"typescript-config-silverwind": "20.0.0",
|
|
45
45
|
"updates": "17.18.0",
|