diff options
| author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-07-25 15:26:18 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-25 06:26:18 +0000 |
| commit | 3d3590063954dd30c1ebea02aad136878eeee04e (patch) | |
| tree | 6bc5fd53d4aa4c0d1d88a715f5e2a019fc9bd64f /cli | |
| parent | e311e46a8f80491bc0ab4bc5dfce55d78bdb7187 (diff) | |
fix(ext/net): fix string port number handling in listen (#19921)
While string `port` is not allowed in typing, it seems we used to
support that and now it's broken. ref:
https://github.com/denoland/deno/issues/10064#issuecomment-1637427260
This PR restores the support of string port number in `listen` and
`listenTls`
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/tests/unit/net_test.ts | 9 | ||||
| -rw-r--r-- | cli/tests/unit/tls_test.ts | 14 |
2 files changed, 23 insertions, 0 deletions
diff --git a/cli/tests/unit/net_test.ts b/cli/tests/unit/net_test.ts index 32250bbd0..ca4c5191c 100644 --- a/cli/tests/unit/net_test.ts +++ b/cli/tests/unit/net_test.ts @@ -1237,3 +1237,12 @@ Deno.test({ }, Deno.errors.AddrInUse); listener1.close(); }); + +Deno.test({ + permissions: { net: true }, +}, function netTcpListenDoesNotThrowOnStringPort() { + // @ts-ignore String port is not allowed by typing, but it shouldn't throw + // for backwards compatibility. + const listener = Deno.listen({ hostname: "localhost", port: "0" }); + listener.close(); +}); diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts index 11691379c..1f0702f62 100644 --- a/cli/tests/unit/tls_test.ts +++ b/cli/tests/unit/tls_test.ts @@ -1477,3 +1477,17 @@ Deno.test({ }, Deno.errors.AddrInUse); listener1.close(); }); + +Deno.test({ + permissions: { net: true }, +}, function listenTlsDoesNotThrowOnStringPort() { + const listener = Deno.listenTls({ + hostname: "localhost", + // @ts-ignore String port is not allowed by typing, but it shouldn't throw + // for backwards compatibility. + port: "0", + cert, + key, + }); + listener.close(); +}); |
