fix(http): show hostname as 'localhost' for 0.0.0.0 on windows (#5918)

This commit is contained in:
Yoshiya Hinosawa 2024-09-05 20:39:02 +09:00 committed by GitHub
parent 149839b60c
commit fb79076121
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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