You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
10 years ago
|
#!/usr/bin/env node
|
||
|
|
||
|
var
|
||
|
app,
|
||
|
modulesPath = process.env.WAPPALYZER_NODE_PATH !== undefined ? process.env.WAPPALYZER_NODE_PATH + '/node_modules/' : '',
|
||
|
json = require(process.env.WAPPALYZER_ROOT + '/src/apps.json');
|
||
|
|
||
|
for ( app in json.apps ) {
|
||
|
['headers', 'html', 'env', 'meta', 'script'].forEach(function(type) {
|
||
|
var
|
||
|
key,
|
||
|
patterns = json.apps[app][type];
|
||
|
|
||
|
if ( patterns !== undefined ) {
|
||
|
patterns = typeof patterns === 'string' ? [patterns] : patterns;
|
||
|
|
||
|
if ( !( patterns instanceof Array ) ) {
|
||
|
patterns = [];
|
||
|
|
||
|
for ( key in json.apps[app][type] ) {
|
||
|
patterns.push(json.apps[app][type][key]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
patterns.forEach(function(pattern) {
|
||
|
var
|
||
|
attrs = pattern.split('\\;'),
|
||
|
regex = '/' + attrs.shift().replace('/', '\/') + '/';
|
||
|
|
||
|
if ( /^\/(?:\^\$|\.\+|\.\*)\/$/.test(regex) ) {
|
||
|
throw new Error('Pattern should be replaced with empty string.\n' + app + ': ' + type + ': ' + pattern);
|
||
|
}
|
||
|
|
||
|
if ( type === 'html' ) {
|
||
|
if ( /\.(?:\+|\*)/.test(regex) ) {
|
||
|
throw new Error('Avoid ".+" and ".*" in HTML patterns. Consider using "[^>]+" or "[^<]+" instead.\n' + app + ': ' + type + ': ' + pattern);
|
||
|
}
|
||
|
|
||
|
if ( !/[<>]/.test(regex) ) {
|
||
|
throw new Error('HTML patterns must contain "<" or ">".\n' + app + ': ' + type + ': ' + pattern);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if ( /[a-z]+:\/\//i.test(json.apps[app].website) ) {
|
||
|
throw new Error('Do not include the protocol in the website URL\n' + app + ': ' + json.apps[app].website);
|
||
|
}
|
||
|
}
|