From 543b60092d4feedabbdcfb0a0d545a013944f43e Mon Sep 17 00:00:00 2001 From: tzy-17 Date: Fri, 17 Jul 2026 04:40:18 +0800 Subject: [PATCH] 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. --- src/cli/container-target.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/container-target.ts b/src/cli/container-target.ts index 0f410af8dd5e..e2706c3c40d8 100644 --- a/src/cli/container-target.ts +++ b/src/cli/container-target.ts @@ -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) {