From 4d307ef90b73952b27724f329a10c0140afd2518 Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Sat, 17 Mar 2018 12:14:28 +1100 Subject: [PATCH] Add cookie detection to NPM driver --- src/drivers/npm/driver.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index c47d6da26..757f07b8f 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -127,12 +127,14 @@ class Driver { const html = this.getHtml(browser); const scripts = this.getScripts(browser); const js = this.getJs(browser); + const cookies = this.getCookies(browser); this.wappalyzer.analyze(pageUrl, { headers, html, scripts, - js + js, + cookies, }) .then(() => { const links = Array.prototype.reduce.call( @@ -267,6 +269,21 @@ class Driver { return js; } + getCookies(browser) { + const cookies = []; + + if ( browser.cookies ) { + browser.cookies.forEach(cookie => cookies.push({ + name: cookie.key, + value: cookie.value, + domain: cookie.domain, + path: cookie.path, + })); + } + + return cookies; + } + crawl(pageUrl, index, depth = 1) { pageUrl.canonical = pageUrl.protocol + '//' + pageUrl.host + pageUrl.pathname;