fix(cli): use startsWith for loopback IPv4 check in container proxy (#106077)

isLoopbackProxyHostname used split(".", 1)[0] === "127" to detect
127.0.0.0/8 addresses. While isIP() already rejects leading-zero octets
before this branch is reached, startsWith("127.") is more direct and
clearly expresses the intent of matching the entire 127.0.0.0/8 range.
This commit is contained in:
tzy-17
2026-07-17 04:40:18 +08:00
committed by GitHub
parent 093b8859c4
commit 543b60092d
+1 -1
View File
@@ -184,7 +184,7 @@ function isLoopbackProxyHostname(hostname: string): boolean {
return true;
}
if (isIP(normalizedHostname) === 4) {
return normalizedHostname.split(".", 1)[0] === "127";
return normalizedHostname.startsWith("127.");
}
const ipv6Hostname = normalizedHostname.replace(/^\[|\]$/g, "");
if (isIP(ipv6Hostname) !== 6) {