mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
refactor: fix ipv6
This commit is contained in:
@@ -27,9 +27,8 @@ function format(hostname: string, port: number) {
|
||||
|
||||
export function serverUrls(hostname: string, port: number) {
|
||||
const bind = format(hostname, port)
|
||||
const wildcard = hostname === "0.0.0.0" || hostname === "::"
|
||||
const local = wildcard ? format("localhost", port) : bind
|
||||
const ip = wildcard ? getNetworkIPs()[0] : undefined
|
||||
const local = hostname === "0.0.0.0" ? format("localhost", port) : hostname === "::" ? format("::1", port) : bind
|
||||
const ip = hostname === "0.0.0.0" ? getNetworkIPs()[0] : undefined
|
||||
|
||||
return {
|
||||
local,
|
||||
|
||||
@@ -52,12 +52,17 @@ describe("server URL display", () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("formats IPv6 bind URLs", () => {
|
||||
test("formats IPv6 bind URLs without advertising IPv4 interfaces", () => {
|
||||
expect(serverUrls("::1", 4096)).toStrictEqual({
|
||||
local: "http://[::1]:4096",
|
||||
network: undefined,
|
||||
bind: "http://[::1]:4096",
|
||||
})
|
||||
expect(serverUrls("::", 4096)).toStrictEqual({
|
||||
local: "http://[::1]:4096",
|
||||
network: undefined,
|
||||
bind: "http://[::]:4096",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user