ip-utilties 3.7.2 → 3.7.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/package.json +1 -1
- package/src/ip.mjs +5 -9
- package/types/ip.d.mts +1 -0
package/package.json
CHANGED
package/src/ip.mjs
CHANGED
|
@@ -19,7 +19,6 @@ const ipv4 = {
|
|
|
19
19
|
segmentMask: 0xffn,
|
|
20
20
|
base: 10,
|
|
21
21
|
localHost: new Uint8Array([127, 0, 0, 1]),
|
|
22
|
-
localHostPrefixLenth: 8,
|
|
23
22
|
|
|
24
23
|
// https://www.geeksforgeeks.org/computer-networks/subnet-cheat-sheet/
|
|
25
24
|
wellKnownAddresses: [
|
|
@@ -63,7 +62,6 @@ const ipv6 = {
|
|
|
63
62
|
segmentMask: 0xffffn,
|
|
64
63
|
base: 16,
|
|
65
64
|
localHost: new Uint16Array([0, 0, 0, 0, 0, 0, 0, 1]),
|
|
66
|
-
localHostPrefixLenth: 128,
|
|
67
65
|
wellKnownAddresses: [
|
|
68
66
|
[new Uint16Array([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 64, 64, true],
|
|
69
67
|
[new Uint16Array([0xfd00, 0, 0, 0, 0, 0, 0, 0]), 8, 64, false, true],
|
|
@@ -299,22 +297,19 @@ export function normalizeCIDR(address) {
|
|
|
299
297
|
const wns = _wellKnownSubnet(family, encoded);
|
|
300
298
|
|
|
301
299
|
if (wns) {
|
|
302
|
-
prefixLength
|
|
300
|
+
prefixLength = prefixLength === undefined ? wns[2] : parseInt(prefixLength);
|
|
301
|
+
|
|
303
302
|
prefix = _decode(
|
|
304
303
|
family,
|
|
305
304
|
_prefix(family, encoded, prefixLength),
|
|
306
305
|
prefixLength
|
|
307
306
|
);
|
|
308
|
-
longPrefix = _decode(family,
|
|
307
|
+
longPrefix = _decode(family, encoded);
|
|
309
308
|
} else {
|
|
310
309
|
prefixLength = prefixLength === undefined ? 0 : parseInt(prefixLength);
|
|
311
310
|
|
|
312
311
|
if (prefixLength) {
|
|
313
312
|
encoded = _prefix(family, prefix, prefixLength);
|
|
314
|
-
} else {
|
|
315
|
-
if (_isLocalhost(family, encoded)) {
|
|
316
|
-
prefixLength = family.localHostPrefixLenth;
|
|
317
|
-
}
|
|
318
313
|
}
|
|
319
314
|
prefix = _decode(family, encoded, prefixLength);
|
|
320
315
|
longPrefix = _decode(family, encoded);
|
|
@@ -324,7 +319,8 @@ export function normalizeCIDR(address) {
|
|
|
324
319
|
longPrefix,
|
|
325
320
|
prefix,
|
|
326
321
|
prefixLength,
|
|
327
|
-
cidr: `${prefix}/${prefixLength}
|
|
322
|
+
cidr: `${prefix}/${prefixLength}`,
|
|
323
|
+
family: family.name
|
|
328
324
|
};
|
|
329
325
|
}
|
|
330
326
|
|
package/types/ip.d.mts
CHANGED
|
@@ -45,6 +45,7 @@ export declare function normalizeCIDR(address: any): {
|
|
|
45
45
|
prefix: any;
|
|
46
46
|
prefixLength: any;
|
|
47
47
|
cidr: string;
|
|
48
|
+
family: string;
|
|
48
49
|
};
|
|
49
50
|
export declare function formatCIDR(address: any, prefixLength: any): any;
|
|
50
51
|
export declare function normalizeIP(address: any): string | undefined;
|