diff --git a/lib/client.js b/lib/client.js index f42e5ac..78ce8cb 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,27 +1,16 @@ var sys = require('sys'); var crypto = require('crypto'); var EventEmitter = require('events').EventEmitter; -var url = require('url'); var Query = require(__dirname + '/query'); var utils = require(__dirname + '/utils'); var defaults = require(__dirname + '/defaults'); var Connection = require(__dirname + '/connection'); -var parseConnectionString = function(str) { - var result = url.parse(str); - result.host = result.hostname; - result.database = result.pathname ? result.pathname.slice(1) : null - var auth = (result.auth || ':').split(':'); - result.user = auth[0]; - result.password = auth[1]; - return result; -}; - var Client = function(config) { EventEmitter.call(this); if(typeof config === 'string') { - config = parseConnectionString(config) + config = utils.parseConnectionString(config) } config = config || {}; this.user = config.user || defaults.user; diff --git a/lib/utils.js b/lib/utils.js index 0402324..32726b8 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,3 +1,4 @@ +var url = require('url'); var events = require('events'); var sys = require('sys'); @@ -75,5 +76,14 @@ p._pulse = function(item, cb) { } module.exports = { - Pool: Pool + Pool: Pool, + parseConnectionString: function(str) { + var result = url.parse(str); + result.host = result.hostname; + result.database = result.pathname ? result.pathname.slice(1) : null + var auth = (result.auth || ':').split(':'); + result.user = auth[0]; + result.password = auth[1]; + return result; + } }