1
0
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:
Matthias Hannig
2018-09-22 12:11:05 +02:00
parent 53e76792e9
commit 7bdf760c40

View File

@ -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);
}