Skip to content

Commit

Permalink
merge conflicts for pull request #98
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag04 committed Feb 19, 2014
2 parents e102344 + 66f0fdb commit f7adeae
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/connect-redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,26 @@ module.exports = function(connect){
? 'sess:'
: options.prefix;

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.pass = userparts[1];
}
}
options.host = url.hostname;
options.port = url.port;
if (url.pathname) {
options.db = url.pathname.replace("/", "", 1);
}
}
}

this.client = options.client || new require('redis').createClient(options.port || options.socket, options.host, options);

if (options.pass) {
this.client.auth(options.pass, function(err){
if (err) throw err;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "connect-redis",
"description": "Redis session store for Connect",
"version": "1.4.6",
"version": "1.4.7",
"author": "TJ Holowaychuk <[email protected]>",
"main": "./index.js",
"repository": { "type": "git", "url": "[email protected]:visionmedia/connect-redis.git" },
Expand Down
2 changes: 2 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var assert = require('assert')

var store = new RedisStore;
var store_alt = new RedisStore({ db: 15 });
var store_url = new RedisStore({ url: "redis://localhost:6379/db2" });

store.client.on('connect', function(){
// #set()
Expand All @@ -27,6 +28,7 @@ store.client.on('connect', function(){
console.log('done');
store.client.end();
store_alt.client.end();
store_url.client.end();
process.exit(0);
});
});
Expand Down

0 comments on commit f7adeae

Please sign in to comment.