Archived
1
0

fix: listening on IPv6 address not possible (#5133)

Wrap IPv6 addresses in square brackets when making URL in ensureAddress,
fixing regression (#1582)
This commit is contained in:
mooff
2022-04-26 20:33:51 +01:00
committed by GitHub
parent 683412cb01
commit a0b36147ea
2 changed files with 15 additions and 4 deletions

View File

@ -94,7 +94,8 @@ export const ensureAddress = (server: http.Server, protocol: string): URL | stri
}
if (typeof addr !== "string") {
return new URL(`${protocol}://${addr.address}:${addr.port}`)
const host = addr.family === "IPv6" ? `[${addr.address}]` : addr.address
return new URL(`${protocol}://${host}:${addr.port}`)
}
// If this is a string then it is a pipe or Unix socket.