From 839941d75f911d7572d518ec838a948ab2960161 Mon Sep 17 00:00:00 2001 From: Jeff Huff Date: Fri, 26 Aug 2011 15:07:10 -0700 Subject: [PATCH] Changed the scheme check order so that the default port can default for both ldap and ldaps --- lib/url.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/url.js b/lib/url.js index 724cb75..6e391f1 100644 --- a/lib/url.js +++ b/lib/url.js @@ -15,16 +15,16 @@ module.exports = { if (!u.protocol || !(u.protocol === 'ldap:' || u.protocol === 'ldaps:')) throw new TypeError(urlStr + ' is an invalid LDAP url (protocol)'); - if (!u.port) { - u.port = 389; - } else { - u.port = parseInt(u.port, 10); - } + u.secure = (u.protocol === 'ldaps:'); if (!u.hostname) u.hostname = 'localhost'; - u.secure = (u.protocol === 'ldaps:'); + if (!u.port) { + u.port = (u.secure ? 636 : 389); + } else { + u.port = parseInt(u.port, 10); + } if (u.pathname) { u.pathname = querystring.unescape(u.pathname.substr(1));