diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index d15961ac9..73be28d8f 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -31,6 +31,7 @@ class Driver { this.origPageUrl = url.parse(pageUrl); this.analyzedPageUrls = []; this.apps = []; + this.meta = {}; this.wappalyzer = new Wappalyzer(); @@ -38,7 +39,7 @@ class Driver { this.wappalyzer.categories = json.categories; this.wappalyzer.driver.log = (message, source, type) => this.log(message, source, type); - this.wappalyzer.driver.displayApps = detected => this.displayApps(detected); + this.wappalyzer.driver.displayApps = (detected, meta, context) => this.displayApps(detected, meta, context); } analyze() { @@ -54,9 +55,11 @@ class Driver { this.options.debug && console.log('[wappalyzer ' + type + ']', '[' + source + ']', message); } - displayApps(detected) { + displayApps(detected, meta) { this.timer('displayApps'); + this.meta = meta; + Object.keys(detected).forEach(appName => { const app = detected[appName]; @@ -179,7 +182,10 @@ class Driver { .then(() => { this.timer('done'); - resolve(this.apps) + resolve({ + applications: this.apps, + meta: this.meta + }); }); }); } diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index e2a07a865..82f6df6fa 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -211,7 +211,7 @@ wappalyzer.driver.log = (message, source, type) => { /** * Display apps */ -wappalyzer.driver.displayApps = (detected, context) => { +wappalyzer.driver.displayApps = (detected, meta, context) => { var tab = context.tab; tabCache[tab.id] = tabCache[tab.id] || { detected: [] }; diff --git a/src/wappalyzer.js b/src/wappalyzer.js index bfa52fd66..6aff40276 100644 --- a/src/wappalyzer.js +++ b/src/wappalyzer.js @@ -51,6 +51,11 @@ class Wappalyzer { this.detected[url] = {}; } + // Additional information + const matches = data.html.match(/]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i); + + const language = matches && matches.length ? matches[1] : null; + Object.keys(this.apps).forEach(appName => { apps[appName] = this.detected[url] && this.detected[url][appName] ? this.detected[url][appName] : new Application(appName, this.apps[appName]); @@ -94,13 +99,13 @@ class Wappalyzer { this.resolveImplies(apps, url); this.cacheDetectedApps(apps, url); - this.trackDetectedApps(apps, url, hostname, data.html); + this.trackDetectedApps(apps, url, hostname, language); if ( Object.keys(apps).length ) { this.log(Object.keys(apps).length + ' apps detected: ' + Object.keys(apps).join(', ') + ' on ' + url, 'core'); } - this.driver.displayApps(this.detected[url], context); + this.driver.displayApps(this.detected[url], { language }, context); } /** @@ -326,7 +331,7 @@ class Wappalyzer { /** * Track detected applications */ - trackDetectedApps(apps, url, hostname, html) { + trackDetectedApps(apps, url, hostname, language) { if ( !( this.driver.ping instanceof Function ) ) { return; } @@ -362,13 +367,8 @@ class Wappalyzer { } }); - // Additional information if ( hostname in this.hostnameCache ) { - var match = html.match(/]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i); - - if ( match && match.length ) { - this.hostnameCache[hostname].meta['language'] = match[1]; - } + this.hostnameCache[hostname].meta['language'] = language; } this.ping();