diff options
author | 2023-05-28 17:20:32 -0300 | |
---|---|---|
committer | 2023-05-28 13:20:32 -0700 | |
commit | 63e2d78e76d2af1e584b91f013011db8034fae2e (patch) | |
tree | eb8ccce1705befc7474f103fcb7ff6617a638717 /src/bun.js | |
parent | 1388ec0d60e77cb0d71475fef33ab5764501b208 (diff) | |
download | bun-63e2d78e76d2af1e584b91f013011db8034fae2e.tar.gz bun-63e2d78e76d2af1e584b91f013011db8034fae2e.tar.zst bun-63e2d78e76d2af1e584b91f013011db8034fae2e.zip |
[node:net] fix createConnection options passing (#3101)
* fixup createConnection
* fix comment
* fixup comment
* also fix it on tls
Diffstat (limited to 'src/bun.js')
-rw-r--r-- | src/bun.js/net.exports.js | 16 | ||||
-rw-r--r-- | src/bun.js/node-tls.exports.js | 17 |
2 files changed, 10 insertions, 23 deletions
diff --git a/src/bun.js/net.exports.js b/src/bun.js/net.exports.js index 14c30effc..3d15eed2b 100644 --- a/src/bun.js/net.exports.js +++ b/src/bun.js/net.exports.js @@ -531,18 +531,12 @@ const Socket = (function (InternalSocket) { ); function createConnection(port, host, connectListener) { - if (typeof host == "function") { - connectListener = host; - host = undefined; + if (typeof port === "object") { + // port is option pass Socket options and let connect handle connection options + return new Socket(port).connect(port, host, connectListener); } - var options = - typeof port == "object" - ? port - : { - host: host, - port: port, - }; - return new Socket(options).connect(options, connectListener); + // port is path or host, let connect handle this + return new Socket().connect(port, host, connectListener); } const connect = createConnection; diff --git a/src/bun.js/node-tls.exports.js b/src/bun.js/node-tls.exports.js index cbbab8e4e..d54b79089 100644 --- a/src/bun.js/node-tls.exports.js +++ b/src/bun.js/node-tls.exports.js @@ -294,19 +294,12 @@ export const CLIENT_RENEG_LIMIT = 3, DEFAULT_MIN_VERSION = "TLSv1.2", DEFAULT_MAX_VERSION = "TLSv1.3", createConnection = (port, host, connectListener) => { - if (typeof host == "function") { - connectListener = host; - host = undefined; + if (typeof port === "object") { + // port is option pass Socket options and let connect handle connection options + return new TLSSocket(port).connect(port, host, connectListener); } - var options = - typeof port == "object" - ? port - : { - host: host, - port: port, - }; - - return new TLSSocket(options).connect(options, connectListener); + // port is path or host, let connect handle this + return new TLSSocket().connect(port, host, connectListener); }, connect = createConnection; |