From ba6487640d12a659888d8b857523fc798ee9bc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsombor=20Par=C3=B3czi?= Date: Sat, 24 Nov 2018 04:32:33 +0100 Subject: [PATCH] Remove split / concat when htmlMaxRows and htmlMaxCols is 0 (#2539) --- src/drivers/npm/driver.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index aa9e6a78b..8d099add3 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -282,13 +282,17 @@ class Driver { let html = ''; try { - html = browser.html() - .replace(new RegExp(`(.{${this.options.htmlMaxCols},}[^>]*>)<`, 'g'), (match, p1) => `${p1}\n<`) - .split('\n') - .slice(0, this.options.htmlMaxRows / 2) - .concat(html.slice(html.length - this.options.htmlMaxRows / 2)) - .map(line => line.substring(0, this.options.htmlMaxCols)) - .join('\n'); + if ((this.options.htmlMaxCols === 0) && (this.options.htmlMaxRows === 0)) { + html = browser.html().replace(new RegExp('<', 'g'), '\n<'); + } else { + html = browser.html() + .replace(new RegExp(`(.{${this.options.htmlMaxCols},}[^>]*>)<`, 'g'), (match, p1) => `${p1}\n<`) + .split('\n') + .slice(0, this.options.htmlMaxRows / 2) + .concat(html.slice(html.length - this.options.htmlMaxRows / 2)) + .map(line => line.substring(0, this.options.htmlMaxCols)) + .join('\n'); + } } catch (error) { this.wappalyzer.log(error.message, 'browser', 'error'); }