Add catch statement

main
Elbert Alias 7 years ago
parent 77574d548c
commit 30ac5b413b

@ -261,6 +261,7 @@ class Driver {
return new Promise(resolve => { return new Promise(resolve => {
this.fetch(pageUrl, index, depth) this.fetch(pageUrl, index, depth)
.catch(() => {})
.then(links => { .then(links => {
if ( links && Boolean(this.options.recursive) && depth < this.options.maxDepth ) { if ( links && Boolean(this.options.recursive) && depth < this.options.maxDepth ) {
return Promise.all(links.map((link, index) => this.crawl(link, index + 1, depth + 1))); return Promise.all(links.map((link, index) => this.crawl(link, index + 1, depth + 1)));

@ -122,17 +122,19 @@ class Wappalyzer {
*/ */
robotsTxtAllows(url) { robotsTxtAllows(url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var parsed = this.parseUrl(url.canonical); var parsed = this.parseUrl(url);
if ( parsed.protocol !== 'http:' && parsed.protocol !== 'https:' ) { if ( parsed.protocol !== 'http:' && parsed.protocol !== 'https:' ) {
reject(); return reject();
} }
this.driver.getRobotsTxt(parsed.host, parsed.protocol === 'https:') this.driver.getRobotsTxt(parsed.host, parsed.protocol === 'https:')
.then(robotsTxt => { .then(robotsTxt => {
robotsTxt.forEach(disallow => parsed.pathname.indexOf(disallow) === 0 && reject()); if (robotsTxt.some(disallowedPath => parsed.pathname.indexOf(disallowedPath) === 0)) {
return reject();
resolve(); } else {
return resolve();
}
}); });
}); });
}; };