Skip to content

Commit 70dc7a2

Browse files
trivikrtargos
authored andcommitted
url: declare iterator inside loop
Refs: #30281 (comment) PR-URL: #30509 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent cd740a2 commit 70dc7a2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/url.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
162162
let end = -1;
163163
let rest = '';
164164
let lastPos = 0;
165-
let i = 0;
166-
for (let inWs = false, split = false; i < url.length; ++i) {
165+
for (let i = 0, inWs = false, split = false; i < url.length; ++i) {
167166
const code = url.charCodeAt(i);
168167

169168
// Find first and last non-whitespace characters for trimming
@@ -295,7 +294,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
295294
let hostEnd = -1;
296295
let atSign = -1;
297296
let nonHost = -1;
298-
for (i = 0; i < rest.length; ++i) {
297+
for (let i = 0; i < rest.length; ++i) {
299298
switch (rest.charCodeAt(i)) {
300299
case CHAR_TAB:
301300
case CHAR_LINE_FEED:
@@ -411,7 +410,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
411410

412411
let questionIdx = -1;
413412
let hashIdx = -1;
414-
for (i = 0; i < rest.length; ++i) {
413+
for (let i = 0; i < rest.length; ++i) {
415414
const code = rest.charCodeAt(i);
416415
if (code === CHAR_HASH) {
417416
this.hash = rest.slice(i);

0 commit comments

Comments
 (0)