mirror of
https://github.com/alice-lg/alice-lg.git
synced 2024-05-11 05:55:03 +00:00
fixed ipv6 handling
This commit is contained in:
@ -6,15 +6,14 @@ export function IPv6ToNumeric(addr) {
|
||||
const parts = addr.split(":"); // let's se what we can do about the :: expansion
|
||||
let expanded = [];
|
||||
|
||||
for (let p of parts) {
|
||||
for (const p of parts) {
|
||||
if (p === "") { continue; }
|
||||
let binary = parseInt(p, 16).toString(2); // Convert to binary
|
||||
while (binary.length < 16) {
|
||||
// Leftpad
|
||||
binary = "0" + binary;
|
||||
binary = "0" + binary; // leftpad
|
||||
}
|
||||
expanded.push(binary);
|
||||
}
|
||||
|
||||
return bigInt(expanded.join(""), 2);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user