Skip to content

Commit

Permalink
url: declare iterator inside loop
Browse files Browse the repository at this point in the history
Refs: #30281 (comment)

PR-URL: #30509
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
trivikr authored and BethGriggs committed Feb 6, 2020
1 parent a22d5e7 commit 6d674d4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,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
Expand Down Expand Up @@ -295,7 +294,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:
Expand Down Expand Up @@ -411,7 +410,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);
Expand Down

0 comments on commit 6d674d4

Please sign in to comment.