Add RegEx error handling in RuleEngine

This commit is contained in:
Joe
2019-01-07 06:12:31 -06:00
parent f1cc449113
commit 293bc934ee

View File

@@ -138,8 +138,12 @@ exports.RuleEngine = class RuleEngine {
} }
reTest(regex, data) { reTest(regex, data) {
try {
let match = regex.match(new RegExp('^/(.*?)/([giumy]*)$')); let match = regex.match(new RegExp('^/(.*?)/([giumy]*)$'));
regex = new RegExp(match[1], match[2]); regex = new RegExp(match[1], match[2]);
} catch (err) {
logger.log("error","Regular Expression processing failed for RegEx " + regex + " is it in the right format?");
}
return regex.test(data); return regex.test(data);
} }
} }