From: Ryan Dahl Date: Fri, 28 Jan 2011 03:24:39 +0000 (-0800) Subject: Fix option parsing in tls.connect() X-Git-Tag: v0.3.7~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df5d5d63422b3624ae3c19c8d4424deacfcd9025;p=platform%2Fupstream%2Fnodejs.git Fix option parsing in tls.connect() --- diff --git a/lib/tls.js b/lib/tls.js index 1f193e7..95f40af 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -650,31 +650,22 @@ Server.prototype.setOptions = function(options) { exports.connect = function(port /* host, options, cb */) { // parse args var host, options = {}, cb; - switch (typeof arguments[1]) { - case 'string': - host = arguments[1]; - if (typeof arguments[2] == 'object') { - options = arguments[2]; - if (typeof arguments[3] == 'function') cb = arguments[3]; - } else if (typeof arguments[2] == 'function') { - cb = arguments[2]; - } - break; - - case 'object': - options = arguments[1]; - if (typeof arguments[2] == 'function') cb = arguments[2]; - break; - - case 'function': - cb = arguments[1]; - break; - - default: - break; + for (var i = 1; i < arguments.length; i++) { + switch (typeof arguments[i]) { + case 'string': + host = arguments[i]; + break; + + case 'object': + options = arguments[i]; + break; + + case 'function': + cb = arguments[i]; + break; + } } - var socket = new net.Stream(); var sslcontext = crypto.createCredentials(options);