mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 20:25:12 -05:00
fix(ext/http): print []
around ipv6 addresses (#24150)
This commit is contained in:
parent
ed13d36e4b
commit
f5d749d922
1 changed files with 8 additions and 2 deletions
|
@ -34,6 +34,7 @@ const {
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
PromisePrototypeCatch,
|
PromisePrototypeCatch,
|
||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
|
StringPrototypeIncludes,
|
||||||
Symbol,
|
Symbol,
|
||||||
TypeError,
|
TypeError,
|
||||||
TypedArrayPrototypeGetSymbolToStringTag,
|
TypedArrayPrototypeGetSymbolToStringTag,
|
||||||
|
@ -656,14 +657,19 @@ function serve(arg1, arg2) {
|
||||||
// If the hostname is "0.0.0.0", we display "localhost" in console
|
// If the hostname is "0.0.0.0", we display "localhost" in console
|
||||||
// because browsers in Windows don't resolve "0.0.0.0".
|
// because browsers in Windows don't resolve "0.0.0.0".
|
||||||
// See the discussion in https://github.com/denoland/deno_std/issues/1165
|
// See the discussion in https://github.com/denoland/deno_std/issues/1165
|
||||||
const hostname = addr.hostname == "0.0.0.0" ? "localhost" : addr.hostname;
|
const hostname = addr.hostname == "0.0.0.0" || addr.hostname == "::"
|
||||||
|
? "localhost"
|
||||||
|
: addr.hostname;
|
||||||
addr.hostname = hostname;
|
addr.hostname = hostname;
|
||||||
|
|
||||||
const onListen = (scheme) => {
|
const onListen = (scheme) => {
|
||||||
if (options.onListen) {
|
if (options.onListen) {
|
||||||
options.onListen(addr);
|
options.onListen(addr);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Listening on ${scheme}${addr.hostname}:${addr.port}/`);
|
const host = StringPrototypeIncludes(addr.hostname, ":")
|
||||||
|
? `[${addr.hostname}]`
|
||||||
|
: addr.hostname;
|
||||||
|
console.log(`Listening on ${scheme}${host}:${addr.port}/`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue