Skip to content

Commit

Permalink
move check to connect function
Browse files Browse the repository at this point in the history
  • Loading branch information
BridgeAR committed Jun 16, 2017
1 parent a4d753f commit dcb6cde
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,6 @@ function internalConnect(

var err;

if (typeof address !== 'string') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'address', 'string');
}

if (localAddress || localPort) {
debug('binding to localAddress: %s and localPort: %d (addressType: %d)',
localAddress, localPort, addressType);
Expand Down Expand Up @@ -969,8 +965,9 @@ Socket.prototype.connect = function() {
this._sockname = null;
}

var pipe = !!options.path;
debug('pipe', pipe, options.path);
const path = options.path;
var pipe = !!path;
debug('pipe', pipe, path);

if (!this._handle) {
this._handle = pipe ? new Pipe() : new TCP();
Expand All @@ -987,7 +984,10 @@ Socket.prototype.connect = function() {
this.writable = true;

if (pipe) {
internalConnect(this, options.path);
if (typeof path !== 'string') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options.path', 'string', path);
}
internalConnect(this, path);
} else {
lookupAndConnect(this, options);
}
Expand Down

0 comments on commit dcb6cde

Please sign in to comment.