diff --git a/lib/adapters/redis.js b/lib/adapters/redis.js index b9bcc935..10c05463 100644 --- a/lib/adapters/redis.js +++ b/lib/adapters/redis.js @@ -8,6 +8,16 @@ var redis = safeRequire('redis'); exports.initialize = function initializeSchema(schema, callback) { if (!redis) return; + if (schema.settings.url) { + var url = require('url'); + var redisUrl = url.parse(schema.settings.url); + var redisAuth = redisUrl.auth.split(':'); + schema.settings.host = redisUrl.hostname; + schema.settings.port = redisUrl.port; + schema.settings.db = redisAuth[0]; + schema.settings.password = redisAuth[1]; + } + schema.client = redis.createClient( schema.settings.port, schema.settings.host, @@ -361,7 +371,7 @@ function applyFilter(filter) { } }); return pass; - } + }; function test(example, value) { if (typeof value === 'string' && example && example.constructor.name === 'RegExp') {