Fix incorrect object iteration

main
Elbert Alias 7 years ago
parent 85ec4c6945
commit 727215463c

@ -114,12 +114,12 @@ class Driver {
headers[header[0]].push(header[1]); headers[header[0]].push(header[1]);
}); });
let html = '';
try { try {
const html = browser.html(); html = browser.html();
} catch ( e ) { } catch ( e ) {
this.wappalyzer.log(error.message, 'browser', 'error'); this.wappalyzer.log(error.message, 'browser', 'error');
const html = '';
} }
const vars = Object.getOwnPropertyNames(browser.window); const vars = Object.getOwnPropertyNames(browser.window);

@ -181,13 +181,17 @@ class Wappalyzer {
* Enclose string in array * Enclose string in array
*/ */
asArray(value) { asArray(value) {
return typeof value === 'string' ? [ value ] : value; return value instanceof Array ? value : [ value ];
} }
/** /**
* Parse apps.json patterns * Parse apps.json patterns
*/ */
parsePatterns(patterns) { parsePatterns(patterns) {
if ( !patterns ) {
return [];
}
var parsed = {}; var parsed = {};
// Convert string to object containing array containing string // Convert string to object containing array containing string
@ -197,7 +201,7 @@ class Wappalyzer {
}; };
} }
for ( var key in patterns ) { Object.keys(patterns).forEach(key => {
parsed[key] = []; parsed[key] = [];
this.asArray(patterns[key]).forEach(pattern => { this.asArray(patterns[key]).forEach(pattern => {
@ -226,7 +230,7 @@ class Wappalyzer {
parsed[key].push(attrs); parsed[key].push(attrs);
}); });
} });
// Convert back to array if the original pattern list was an array (or string) // Convert back to array if the original pattern list was an array (or string)
if ( 'main' in parsed ) { if ( 'main' in parsed ) {