diff --git a/src/core/lib/IP.mjs b/src/core/lib/IP.mjs index 7eab1f33..0393f8d9 100644 --- a/src/core/lib/IP.mjs +++ b/src/core/lib/IP.mjs @@ -397,14 +397,9 @@ export function strToIpv6(ipStr, retArr=true) { */ export function expandIpv6(ipStr) { const compactIndex = ipStr.search("::"); - if (compactIndex === -1) { - // There were no occurances of '::' - // in ipStr. - return ipStr; - } let expandedStr = ipStr.substring(0, compactIndex); // 1234:5678::.. const insertOffset = compactIndex == 0; - const ipEnd = ipStr.substring(compactIndex + 1); + const ipEnd = ipStr.substring(compactIndex + 1); // :7ABC:DEFG:... const missingChars = 39 - (expandedStr.length + ipEnd.length); for (let i = insertOffset; i < missingChars + insertOffset; i++) { if (i % 5 == 0) { @@ -413,6 +408,10 @@ export function strToIpv6(ipStr, retArr=true) { } expandedStr += "0"; } + if (compactIndex === ipStr.length - 2) { + expandedStr = expandedStr + "0"; + return expandedStr; + } expandedStr += ipEnd; return expandedStr; }