First Commit of new way of building the Platform
This commit is contained in:
1 parent
e48cf0dae5
commit
40e60b42cc
4616 files changed
+713402
No files matched your search
+46
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
var env = require('env-variable');
|
||||
|
||||
/**
|
||||
* Checks if a given namespace is allowed by the environment variables.
|
||||
*
|
||||
* @param {String} name namespace that should be included.
|
||||
* @param {Array} variables
|
||||
* @returns {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
module.exports = function enabled(name, variables) {
|
||||
var envy = env()
|
||||
, variable
|
||||
, i = 0;
|
||||
|
||||
variables = variables || ['diagnostics', 'debug'];
|
||||
|
||||
for (; i < variables.length; i++) {
|
||||
if ((variable = envy[variables[i]])) break;
|
||||
}
|
||||
|
||||
if (!variable) return false;
|
||||
|
||||
variables = variable.split(/[\s,]+/);
|
||||
i = 0;
|
||||
|
||||
for (; i < variables.length; i++) {
|
||||
variable = variables[i].replace('*', '.*?');
|
||||
|
||||
if ('-' === variable.charAt(0)) {
|
||||
if ((new RegExp('^'+ variable.substr(1) +'$')).test(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((new RegExp('^'+ variable +'$')).test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
Reference in new issue
Block a user