Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var rule = /^\s*([$\w]+)\s*(?:=\s*(?:(['"])((?:(?!\2)[^\\]|\\.)*)\2|(.+))\s*)?$/;
var nativeValues = ['true', 'false', 'null', 'undefined'];
for (var i = 0, j = params.length; i < j; i++) {
var param = params[i];
if (rule.test(param)) {
var key = RegExp.$1, strValue = RegExp.$3, plainValue = RegExp.$4;
if (config.hasOwnProperty(key)) {
throw new Error("the config of \"" + key + "\" has exists,do not define again.");
}
if (strValue) {
config[key] = utils_1.decodeTrans(strValue);
}
else if (plainValue) {
var value = plainValue;
if (value.charAt(0) === '/') {
if (reregexp_1.regexpRule.test(value)) {
config[key] = utils_1.getExp(value);
}
else {
this.halt("wrong regexp:" + value);
}
}
else if (!isNaN(Number(value))) {
config[key] = Number(value);
}
else if (nativeValues.indexOf(value) > -1) {
config[key] = utils_1.getExp(value);
}
else {
this.halt("wrong param:" + param);
}
}
this.addRule('Regexp', function (Regexp) {
if (!Regexp) {
throw new Error("the regexp type must has a regexp rule.");
}
var rule = Regexp.rule;
if (!reregexp_1.regexpRule.test(rule)) {
throw new Error('wrong regexp expression');
}
});
this.addRule('Config', function (Config) {