Merge pull request #960 from q--/Create_RegExp_objects_to_check_for_errors

Check if patterns are valid regular expressions by creating a new RegExp object for each of them
main
Elbert Alias 9 years ago
commit 225d394fe0

@ -27,6 +27,11 @@ for ( app in json.apps ) {
attrs = pattern.split('\\;'),
regex = '/' + attrs.shift().replace('/', '\/') + '/';
//Check if the pattern is a valid RegExp
//Note: unlike when used in Wappalyzer, the modifier i isn't added here
new RegExp(regex);
if ( /^\/(?:\^\$|\.\+|\.\*)\/$/.test(regex) ) {
throw new Error('Pattern should be replaced with empty string.\n' + app + ': ' + type + ': ' + pattern);
}

Loading…
Cancel
Save