ip-utilties 3.7.0 → 3.7.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/package.json +4 -9
- package/src/ip.mjs +16 -24
- package/types/ip.d.mts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ip-utilties",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -42,17 +42,12 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"ava": "^8.0.1",
|
|
45
|
-
"browser-ava": "^2.3.
|
|
46
|
-
"c8": "^
|
|
45
|
+
"browser-ava": "^2.3.69",
|
|
46
|
+
"c8": "^12.0.0",
|
|
47
47
|
"documentation": "^14.0.3",
|
|
48
|
-
"semantic-release": "^25.0.
|
|
48
|
+
"semantic-release": "^25.0.8",
|
|
49
49
|
"typescript": "^7.0.2"
|
|
50
50
|
},
|
|
51
|
-
"overrides": {
|
|
52
|
-
"c8": {
|
|
53
|
-
"yargs": "^18.0.0"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
51
|
"engines": {
|
|
57
52
|
"node": ">=26.4.0"
|
|
58
53
|
},
|
package/src/ip.mjs
CHANGED
|
@@ -219,6 +219,12 @@ function _is(family, address) {
|
|
|
219
219
|
return (
|
|
220
220
|
address instanceof family.factory && address.length === family.segments
|
|
221
221
|
);
|
|
222
|
+
|
|
223
|
+
case "bigint": {
|
|
224
|
+
if (family === ipv6 && address > 1n << BigInt(ipv4.bitLength)) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
222
228
|
}
|
|
223
229
|
|
|
224
230
|
return false;
|
|
@@ -292,8 +298,8 @@ export function normalizeCIDR(address) {
|
|
|
292
298
|
let encoded = _encode(family, prefix);
|
|
293
299
|
const wns = _wellKnownSubnet(family, encoded);
|
|
294
300
|
|
|
295
|
-
if (wns
|
|
296
|
-
prefixLength
|
|
301
|
+
if (wns) {
|
|
302
|
+
prefixLength ||= wns[2];
|
|
297
303
|
prefix = _decode(
|
|
298
304
|
family,
|
|
299
305
|
_prefix(family, encoded, prefixLength),
|
|
@@ -301,31 +307,17 @@ export function normalizeCIDR(address) {
|
|
|
301
307
|
);
|
|
302
308
|
longPrefix = _decode(family, wns[0]);
|
|
303
309
|
} else {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (family === ipv6) {
|
|
310
|
-
if (!prefix.endsWith("::")) {
|
|
311
|
-
// TODO
|
|
312
|
-
prefix += prefix.endsWith(":") ? ":" : "::";
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
longPrefix = prefix;
|
|
310
|
+
prefixLength = prefixLength === undefined ? 0 : parseInt(prefixLength);
|
|
311
|
+
|
|
312
|
+
if (prefixLength) {
|
|
313
|
+
encoded = _prefix(family, prefix, prefixLength);
|
|
316
314
|
} else {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (prefixLength) {
|
|
320
|
-
encoded = _prefix(family, prefix, prefixLength);
|
|
321
|
-
} else {
|
|
322
|
-
if (_isLocalhost(family, encoded)) {
|
|
323
|
-
prefixLength = family.localHostPrefixLenth;
|
|
324
|
-
}
|
|
315
|
+
if (_isLocalhost(family, encoded)) {
|
|
316
|
+
prefixLength = family.localHostPrefixLenth;
|
|
325
317
|
}
|
|
326
|
-
prefix = _decode(family, encoded, prefixLength);
|
|
327
|
-
longPrefix = _decode(family, encoded);
|
|
328
318
|
}
|
|
319
|
+
prefix = _decode(family, encoded, prefixLength);
|
|
320
|
+
longPrefix = _decode(family, encoded);
|
|
329
321
|
}
|
|
330
322
|
|
|
331
323
|
return {
|
package/types/ip.d.mts
CHANGED
|
@@ -41,7 +41,7 @@ export declare function prefixOnlyIP(address: any, length: any): string;
|
|
|
41
41
|
export declare function rangeIP(address: any, prefix: any, lowerAdd?: number, upperReduce?: number): any[];
|
|
42
42
|
export declare function matchPrefixIP(prefix: any, length: any, address: any): boolean;
|
|
43
43
|
export declare function normalizeCIDR(address: any): {
|
|
44
|
-
longPrefix:
|
|
44
|
+
longPrefix: string;
|
|
45
45
|
prefix: any;
|
|
46
46
|
prefixLength: any;
|
|
47
47
|
cidr: string;
|