From 9c32b24b652725af6e5a65994e2e6ec57d999fa0 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Sat, 16 Nov 2019 18:51:51 -0800 Subject: [PATCH] url: declare iterator inside loop Refs: https://github.com/nodejs/node/pull/30281#discussion_r343380565 PR-URL: https://github.com/nodejs/node/pull/30509 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- lib/url.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/url.js b/lib/url.js index 316b2a12ee4524..735390dfd2e59b 100644 --- a/lib/url.js +++ b/lib/url.js @@ -166,8 +166,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { let end = -1; let rest = ''; let lastPos = 0; - let i = 0; - for (let inWs = false, split = false; i < url.length; ++i) { + for (let i = 0, inWs = false, split = false; i < url.length; ++i) { const code = url.charCodeAt(i); // Find first and last non-whitespace characters for trimming @@ -299,7 +298,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { let hostEnd = -1; let atSign = -1; let nonHost = -1; - for (i = 0; i < rest.length; ++i) { + for (let i = 0; i < rest.length; ++i) { switch (rest.charCodeAt(i)) { case CHAR_TAB: case CHAR_LINE_FEED: @@ -415,7 +414,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { let questionIdx = -1; let hashIdx = -1; - for (i = 0; i < rest.length; ++i) { + for (let i = 0; i < rest.length; ++i) { const code = rest.charCodeAt(i); if (code === CHAR_HASH) { this.hash = rest.slice(i);