1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 12:58:54 -05:00

fix: net listen crashes on explicit undefined hostname (#7706)

This commit is contained in:
Giorgi Rostomashvili 2020-09-27 16:44:53 +02:00 committed by GitHub
parent df02e31507
commit eaba9adb03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -203,10 +203,10 @@
}
}
function listen(options) {
function listen({ hostname, ...options }) {
const res = opListen({
transport: "tcp",
hostname: "0.0.0.0",
hostname: typeof hostname === "undefined" ? "0.0.0.0" : hostname,
...options,
});

View file

@ -533,3 +533,14 @@ unitTest(
await resolvable;
},
);
unitTest(
{
perms: { net: true },
},
function netExplicitUndefinedHostname() {
const listener = Deno.listen({ hostname: undefined, port: 8080 });
assertEquals((listener.addr as Deno.NetAddr).hostname, "0.0.0.0");
listener.close();
},
);