Skip to content

Commit

Permalink
Allow passing in a custom createConnection function
Browse files Browse the repository at this point in the history
  • Loading branch information
tbn-mm authored Oct 13, 2022
1 parent 966f9d4 commit 4889245
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ function initAsClient(websocket, address, protocols, options) {
followRedirects: false,
maxRedirects: 10,
...options,
createConnection: undefined,
socketPath: undefined,
hostname: undefined,
protocol: undefined,
Expand Down Expand Up @@ -706,7 +705,7 @@ function initAsClient(websocket, address, protocols, options) {
const protocolSet = new Set();
let perMessageDeflate;

opts.createConnection = isSecure ? tlsConnect : netConnect;
opts.createConnection = opts.createConnection ?? (isSecure ? tlsConnect : netConnect);
opts.defaultPort = opts.defaultPort || defaultPort;
opts.port = parsedUrl.port || defaultPort;
opts.host = parsedUrl.hostname.startsWith('[')
Expand Down

0 comments on commit 4889245

Please sign in to comment.