fix(http): invalid ipv6 hostname printed to console (#5924)

This commit is contained in:
Marvin Hagemeister 2024-09-10 08:38:03 +02:00 committed by GitHub
parent b3e1ebb75f
commit 9f19c9afa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -842,7 +842,10 @@ function main() {
const host = (Deno.build.os === "windows" && hostname === "0.0.0.0")
? "localhost"
: hostname;
let message = `Listening on:\n- Local: ${protocol}://${host}:${port}`;
const formattedHost = hostname.includes(":") ? `[${host}]` : host;
let message =
`Listening on:\n- Local: ${protocol}://${formattedHost}:${port}`;
if (networkAddress && !DENO_DEPLOYMENT_ID) {
message += `\n- Network: ${protocol}://${networkAddress}:${port}`;
}