Skip to content

Commit 708de4c

Browse files
committed
Merge pull request #94 from hgcummings/issue-93
Fixes #93 by passing full URI to redis.createClient when specified
2 parents e2da797 + 4e5c798 commit 708de4c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

index.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ function adapter(uri, opts){
3434
uri = null;
3535
}
3636

37-
// handle uri string
38-
if (uri) {
39-
uri = uri.split(':');
40-
opts.host = uri[0];
41-
opts.port = uri[1];
42-
}
43-
4437
// opts
45-
var host = opts.host || '127.0.0.1';
46-
var port = Number(opts.port || 6379);
4738
var pub = opts.pubClient;
4839
var sub = opts.subClient;
4940
var prefix = opts.key || 'socket.io';
5041
var subEvent = opts.subEvent || 'message';
5142

5243
// init clients if needed
53-
if (!pub) pub = redis(port, host);
54-
if (!sub) sub = redis(port, host, { return_buffers: true });
44+
function createClient(redis_opts) {
45+
if (uri) {
46+
// handle uri string
47+
return redis(uri, redis_opts);
48+
} else {
49+
return redis(opts.port, opts.host, redis_opts);
50+
}
51+
}
52+
53+
if (!pub) pub = createClient();
54+
if (!sub) sub = createClient({ return_buffers: true });
5555

5656
// this server's key
5757
var uid = uid2(6);

0 commit comments

Comments
 (0)