ip-utilties 3.7.1 → 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 +10 -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
|
@@ -298,8 +298,8 @@ export function normalizeCIDR(address) {
|
|
|
298
298
|
let encoded = _encode(family, prefix);
|
|
299
299
|
const wns = _wellKnownSubnet(family, encoded);
|
|
300
300
|
|
|
301
|
-
if (wns
|
|
302
|
-
prefixLength
|
|
301
|
+
if (wns) {
|
|
302
|
+
prefixLength ||= wns[2];
|
|
303
303
|
prefix = _decode(
|
|
304
304
|
family,
|
|
305
305
|
_prefix(family, encoded, prefixLength),
|
|
@@ -307,31 +307,17 @@ export function normalizeCIDR(address) {
|
|
|
307
307
|
);
|
|
308
308
|
longPrefix = _decode(family, wns[0]);
|
|
309
309
|
} else {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (family === ipv6) {
|
|
316
|
-
if (!prefix.endsWith("::")) {
|
|
317
|
-
// TODO
|
|
318
|
-
prefix += prefix.endsWith(":") ? ":" : "::";
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
longPrefix = prefix;
|
|
310
|
+
prefixLength = prefixLength === undefined ? 0 : parseInt(prefixLength);
|
|
311
|
+
|
|
312
|
+
if (prefixLength) {
|
|
313
|
+
encoded = _prefix(family, prefix, prefixLength);
|
|
322
314
|
} else {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (prefixLength) {
|
|
326
|
-
encoded = _prefix(family, prefix, prefixLength);
|
|
327
|
-
} else {
|
|
328
|
-
if (_isLocalhost(family, encoded)) {
|
|
329
|
-
prefixLength = family.localHostPrefixLenth;
|
|
330
|
-
}
|
|
315
|
+
if (_isLocalhost(family, encoded)) {
|
|
316
|
+
prefixLength = family.localHostPrefixLenth;
|
|
331
317
|
}
|
|
332
|
-
prefix = _decode(family, encoded, prefixLength);
|
|
333
|
-
longPrefix = _decode(family, encoded);
|
|
334
318
|
}
|
|
319
|
+
prefix = _decode(family, encoded, prefixLength);
|
|
320
|
+
longPrefix = _decode(family, encoded);
|
|
335
321
|
}
|
|
336
322
|
|
|
337
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;
|