1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00

fix(ext/http): Include hostname in onListen argument (#19497)

Closes #19470.
This commit is contained in:
Jhan S. Álvarez 2023-06-14 07:58:41 -05:00 committed by GitHub
parent ec8e9d4f5b
commit 4b67ffe11b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -635,16 +635,17 @@ function serve(arg1, arg2) {
}
const onListen = (scheme) => {
// If the hostname is "0.0.0.0", we display "localhost" in console
// because browsers in Windows don't resolve "0.0.0.0".
// See the discussion in https://github.com/denoland/deno_std/issues/1165
const hostname = listenOpts.hostname == "0.0.0.0"
? "localhost"
: listenOpts.hostname;
const port = listenOpts.port;
if (options.onListen) {
options.onListen({ port });
options.onListen({ hostname, port });
} else {
// If the hostname is "0.0.0.0", we display "localhost" in console
// because browsers in Windows don't resolve "0.0.0.0".
// See the discussion in https://github.com/denoland/deno_std/issues/1165
const hostname = listenOpts.hostname == "0.0.0.0"
? "localhost"
: listenOpts.hostname;
console.log(`Listening on ${scheme}${hostname}:${port}/`);
}
};