From 7f99a67f70779fa7802e32b5174cb649b714ed72 Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Fri, 7 Aug 2020 08:18:18 +1000 Subject: [PATCH] Add file:// support, fix timeout in NPM driver --- src/apps.json | 9 ++++----- src/drivers/npm/driver.js | 21 ++++++++++----------- src/drivers/npm/package.json | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/apps.json b/src/apps.json index 12d936c35..29b7a7797 100644 --- a/src/apps.json +++ b/src/apps.json @@ -11194,10 +11194,8 @@ 10 ], "icon": "splitbee.svg", - "js": { - "splitbee": "" - }, "script": "^https://cdn\\.splitbee\\.io/sb\\.js", + "js": { "splitbee": "" }, "website": "https://splitbee.io" }, "Splunk": { @@ -11395,6 +11393,7 @@ "website": "https://strikingly.com" }, "Stripe": { + "description": "Stripe offers online payment processing for internet businesses.", "cats": [ 41 ], @@ -12707,10 +12706,10 @@ "website": "https://www.volusion.com" }, "Vue.js": { + "description": "Vue is a progressive framework for building user interfaces.", "cats": [ 12 ], - "description": "Vue is a progressive framework for building user interfaces.", "html": "<[^>]+\\sdata-v(?:ue)?-", "icon": "vue.svg", "js": { @@ -15478,4 +15477,4 @@ "priority": 6 } } -} \ No newline at end of file +} diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index d0e17f904..62879c536 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -197,10 +197,9 @@ class Site { timeout() { return new Promise((resolve, reject) => - setTimeout( - () => reject(new Error('The website took too long to respond')), - this.options.maxWait - ) + setTimeout(() => { + reject(new Error('The website took too long to respond')) + }, this.options.maxWait) ) } @@ -301,7 +300,7 @@ class Site { try { await Promise.race([ - await this.timeout(), + this.timeout(), page.goto(url.href, { waitUntil: 'domcontentloaded' }) ]) @@ -309,7 +308,7 @@ class Site { // Links const links = await Promise.race([ - await this.timeout(), + this.timeout(), ( await page.evaluateHandle(() => Array.from(document.getElementsByTagName('a')).map( @@ -328,7 +327,7 @@ class Site { // Script tags const scripts = await Promise.race([ - await this.timeout(), + this.timeout(), ( await page.evaluateHandle(() => Array.from(document.getElementsByTagName('script')) @@ -340,7 +339,7 @@ class Site { // Meta tags const meta = await Promise.race([ - await this.timeout(), + this.timeout(), ( await page.evaluateHandle(() => Array.from(document.querySelectorAll('meta')).reduce( @@ -362,7 +361,7 @@ class Site { // JavaScript const js = await Promise.race([ - await this.timeout(), + this.timeout(), page.evaluate( (technologies) => { return technologies.reduce((technologies, { name, chains }) => { @@ -432,7 +431,7 @@ class Site { } // Validate response - if (!this.analyzedUrls[url.href].status) { + if (url.protocol !== 'file:' && !this.analyzedUrls[url.href].status) { await page.close() this.log('Page closed') @@ -442,7 +441,7 @@ class Site { if (!this.language) { this.language = await Promise.race([ - await this.timeout(), + this.timeout(), ( await page.evaluateHandle( () => diff --git a/src/drivers/npm/package.json b/src/drivers/npm/package.json index 79aed97ac..0b2641eca 100644 --- a/src/drivers/npm/package.json +++ b/src/drivers/npm/package.json @@ -38,4 +38,4 @@ "languagedetect": "^2.0.0", "puppeteer": "^2.0.0" } -} \ No newline at end of file +}