summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/rt/30_net.js4
-rw-r--r--cli/tests/unit/net_test.ts11
2 files changed, 13 insertions, 2 deletions
diff --git a/cli/rt/30_net.js b/cli/rt/30_net.js
index 53de5200d..9a71f0693 100644
--- a/cli/rt/30_net.js
+++ b/cli/rt/30_net.js
@@ -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,
});
diff --git a/cli/tests/unit/net_test.ts b/cli/tests/unit/net_test.ts
index 2c6134318..8eaabdbba 100644
--- a/cli/tests/unit/net_test.ts
+++ b/cli/tests/unit/net_test.ts
@@ -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();
+ },
+);