summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJhan S. Álvarez <51450231+yastanotheruser@users.noreply.github.com>2023-06-14 07:58:41 -0500
committerGitHub <noreply@github.com>2023-06-14 06:58:41 -0600
commit4b67ffe11b793040c981da5797d1d4f68ef521d3 (patch)
tree385f300f8bc035573ee75e12d72221169335f494
parentec8e9d4f5bd2c8eed5f086356c1c6dd7c8b40b7f (diff)
fix(ext/http): Include hostname in onListen argument (#19497)
Closes #19470.
-rw-r--r--ext/http/00_serve.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/http/00_serve.js b/ext/http/00_serve.js
index be9c9d801..761c3219e 100644
--- a/ext/http/00_serve.js
+++ b/ext/http/00_serve.js
@@ -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}/`);
}
};