Enable setting up Redis with URL
This commit is contained in:
parent
87a8172b82
commit
24e051b1e9
|
@ -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') {
|
||||
|
|
Loading…
Reference in New Issue