From 681fd2f6b41a3675d7b3113357e2cb3294413e7f Mon Sep 17 00:00:00 2001 From: joaoafrmartins Date: Fri, 10 Jan 2014 00:17:52 +0000 Subject: [PATCH] added regexp filtering to nconf env store --- lib/nconf/stores/env.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/nconf/stores/env.js b/lib/nconf/stores/env.js index e73026e..b3227c7 100644 --- a/lib/nconf/stores/env.js +++ b/lib/nconf/stores/env.js @@ -21,6 +21,7 @@ var Env = exports.Env = function (options) { options = options || {}; this.type = 'env'; this.readOnly = true; + this.match = options.match this.whitelist = options.whitelist || []; this.separator = options.separator || ''; if (options instanceof Array) { @@ -52,7 +53,11 @@ Env.prototype.loadEnv = function () { this.readOnly = false; Object.keys(process.env).filter(function (key) { - return !self.whitelist.length || self.whitelist.indexOf(key) !== -1; + if(self.match) { + return key.match(self.match) + } else { + return !self.whitelist.length || self.whitelist.indexOf(key) !== -1 + } }).forEach(function (key) { if (self.separator) { self.set(common.key.apply(common, key.split(self.separator)), process.env[key]);