Disable robots.txt fetching when tracking is disabled

main
Elbert Alias 8 years ago
parent 123058f69b
commit f4850308e4

@ -266,38 +266,43 @@ wappalyzer.driver.displayApps = (detected, context) => {
*/ */
wappalyzer.driver.getRobotsTxt = (host, secure = false) => { wappalyzer.driver.getRobotsTxt = (host, secure = false) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getOption('robotsTxtCache') getOption('tracking', true)
.then(robotsTxtCache => { .then(tracking => {
robotsTxtCache = robotsTxtCache || {}; if ( !tracking ) {
return resolve([]);
if ( host in robotsTxtCache ) { }
resolve(robotsTxtCache[host]);
} else {
var url = 'http' + ( secure ? 's' : '' ) + '://' + host + '/robots.txt';
fetch('http' + ( secure ? 's' : '' ) + '://' + host + '/robots.txt')
.then(response => {
if ( !response.ok ) {
if ( response.status === 404 ) {
return '';
} else {
throw 'GET ' + response.url + ' was not ok';
}
}
return response.text();
})
.then(robotsTxt => {
robotsTxtCache[host] = wappalyzer.parseRobotsTxt(robotsTxt);
setOption('robotsTxtCache', robotsTxtCache); getOption('robotsTxtCache')
.then(robotsTxtCache => {
robotsTxtCache = robotsTxtCache || {};
if ( host in robotsTxtCache ) {
resolve(robotsTxtCache[host]); resolve(robotsTxtCache[host]);
} else {
var hostname = host.replace(/:[0-9]+$/, '') const url = 'http' + ( secure ? 's' : '' ) + '://' + host + '/robots.txt';
})
.catch(reject); fetch('http' + ( secure ? 's' : '' ) + '://' + host + '/robots.txt')
} .then(response => {
if ( !response.ok ) {
if ( response.status === 404 ) {
return '';
} else {
throw 'GET ' + response.url + ' was not ok';
}
}
return response.text();
})
.then(robotsTxt => {
robotsTxtCache[host] = wappalyzer.parseRobotsTxt(robotsTxt);
setOption('robotsTxtCache', robotsTxtCache);
resolve(robotsTxtCache[host]);
})
.catch(reject);
}
});
}); });
}); });
}; };