diff options
Diffstat (limited to 'src')
-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; |