sessionstore
Advanced tools
Comparing version 0.4.6 to 0.4.7
@@ -21,2 +21,20 @@ var util = require(process.binding('natives').util ? 'util' : 'sys'), | ||
if (options.url) { | ||
var url = require('url').parse(options.url); | ||
if (url.protocol === 'redis:') { | ||
if (url.auth) { | ||
var userparts = url.auth.split(":"); | ||
options.user = userparts[0]; | ||
if (userparts.length === 2) { | ||
options.password = userparts[1]; | ||
} | ||
} | ||
options.host = url.hostname; | ||
options.port = url.port; | ||
if (url.pathname) { | ||
options.db = url.pathname.replace("/", "", 1); | ||
} | ||
} | ||
} | ||
this.client = new redis.createClient(options.port || options.socket, options.host, options); | ||
@@ -28,13 +46,19 @@ | ||
var calledBack = false; | ||
if (options.password) { | ||
this.client.auth(options.password, function(err) { | ||
if (err && !calledBack && callback) { | ||
calledBack = true; | ||
if (callback) callback(err, self); | ||
return; | ||
} | ||
if (err) throw err; | ||
}); | ||
} | ||
if (options.db) { | ||
this.client.select(options.db); | ||
this.client.on("connect", function () { | ||
self.client.send_anyways = true; | ||
self.client.select(options.db); | ||
self.client.send_anyways = false; | ||
}); | ||
} | ||
var calledBack = false; | ||
this.client.on('error', function () { | ||
@@ -49,2 +73,8 @@ self.emit('disconnect'); | ||
this.client.on('connect', function () { | ||
if (options.db) { | ||
self.client.send_anyways = true; | ||
self.client.select(options.db); | ||
self.client.send_anyways = false; | ||
} | ||
self.emit('connect'); | ||
@@ -51,0 +81,0 @@ |
{ | ||
"author": "adrai", | ||
"name": "sessionstore", | ||
"version": "0.4.6", | ||
"version": "0.4.7", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
# Introduction | ||
[![Build Status](https://secure.travis-ci.org/adrai/sessionstore.svg)](http://travis-ci.org/adrai/sessionstore) | ||
[![travis](https://img.shields.io/travis/adrai/sessionstore.svg)](https://travis-ci.org/adrai/sessionstore) [![npm](https://img.shields.io/npm/v/sessionstore.svg)](https://npmjs.org/package/sessionstore) | ||
@@ -162,2 +162,2 @@ Sessionstore is a node.js module for multiple databases. It can be very useful if you work with express or connect. | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
THE SOFTWARE. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34209
754
163