Skip to content

Commit 4727470

Browse files
mscdexrvagg
authored andcommitted
url: fix lint and deopt issues
The deopt issues arose from the use of const in specific situations that v8 does not fully support yet. Fixes: #5299 PR-URL: #5300 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 729ad75 commit 4727470

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

lib/url.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,18 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
8181
var end = -1;
8282
var rest = '';
8383
var lastPos = 0;
84-
for (var i = 0, inWs = false, split = false; i < url.length; ++i) {
85-
var code = url.charCodeAt(i);
84+
var i = 0;
85+
for (var inWs = false, split = false; i < url.length; ++i) {
86+
const code = url.charCodeAt(i);
8687

8788
// Find first and last non-whitespace characters for trimming
88-
var isWs = code === 32/* */ ||
89-
code === 9/*\t*/ ||
90-
code === 13/*\r*/ ||
91-
code === 10/*\n*/ ||
92-
code === 12/*\f*/ ||
93-
code === 160/*\u00A0*/ ||
94-
code === 65279/*\uFEFF*/;
89+
const isWs = code === 32/* */ ||
90+
code === 9/*\t*/ ||
91+
code === 13/*\r*/ ||
92+
code === 10/*\n*/ ||
93+
code === 12/*\f*/ ||
94+
code === 160/*\u00A0*/ ||
95+
code === 65279/*\uFEFF*/;
9596
if (start === -1) {
9697
if (isWs)
9798
continue;
@@ -153,7 +154,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
153154

154155
if (!slashesDenoteHost && !hasHash) {
155156
// Try fast path regexp
156-
var simplePath = simplePathPattern.exec(rest);
157+
const simplePath = simplePathPattern.exec(rest);
157158
if (simplePath) {
158159
this.path = rest;
159160
this.href = rest;
@@ -215,7 +216,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
215216
var hostEnd = -1;
216217
var atSign = -1;
217218
var nonHost = -1;
218-
for (var i = 0; i < rest.length; ++i) {
219+
for (i = 0; i < rest.length; ++i) {
219220
switch (rest.charCodeAt(i)) {
220221
case 9: // '\t'
221222
case 10: // '\n'
@@ -255,7 +256,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
255256
if (hostEnd !== -1)
256257
break;
257258
}
258-
var start = 0;
259+
start = 0;
259260
if (atSign !== -1) {
260261
this.auth = decodeURIComponent(rest.slice(0, atSign));
261262
start = atSign + 1;
@@ -284,9 +285,8 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
284285
hostname.charCodeAt(hostname.length - 1) === 93/*]*/;
285286

286287
// validate a little.
287-
var result;
288288
if (!ipv6Hostname) {
289-
result = validateHostname(this, rest, hostname);
289+
const result = validateHostname(this, rest, hostname);
290290
if (result !== undefined)
291291
rest = result;
292292
}
@@ -326,15 +326,15 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
326326
// First, make 100% sure that any "autoEscape" chars get
327327
// escaped, even if encodeURIComponent doesn't think they
328328
// need to be.
329-
result = autoEscapeStr(rest);
329+
const result = autoEscapeStr(rest);
330330
if (result !== undefined)
331331
rest = result;
332332
}
333333

334334
var questionIdx = -1;
335335
var hashIdx = -1;
336-
for (var i = 0; i < rest.length; ++i) {
337-
var code = rest.charCodeAt(i);
336+
for (i = 0; i < rest.length; ++i) {
337+
const code = rest.charCodeAt(i);
338338
if (code === 35/*#*/) {
339339
this.hash = rest.slice(i);
340340
hashIdx = i;
@@ -378,8 +378,8 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
378378

379379
// to support http.request
380380
if (this.pathname || this.search) {
381-
var p = this.pathname || '';
382-
var s = this.search || '';
381+
const p = this.pathname || '';
382+
const s = this.search || '';
383383
this.path = p + s;
384384
}
385385

@@ -720,17 +720,17 @@ Url.prototype.resolveObject = function(relative) {
720720
return result;
721721
}
722722

723-
const isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
724-
const isRelAbs = (
723+
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
724+
var isRelAbs = (
725725
relative.host ||
726726
relative.pathname && relative.pathname.charAt(0) === '/'
727727
);
728728
var mustEndAbs = (isRelAbs || isSourceAbs ||
729729
(result.host && relative.pathname));
730-
const removeAllDots = mustEndAbs;
730+
var removeAllDots = mustEndAbs;
731731
var srcPath = result.pathname && result.pathname.split('/') || [];
732-
const relPath = relative.pathname && relative.pathname.split('/') || [];
733-
const psychotic = result.protocol && !slashedProtocol[result.protocol];
732+
var relPath = relative.pathname && relative.pathname.split('/') || [];
733+
var psychotic = result.protocol && !slashedProtocol[result.protocol];
734734

735735
// if the url is a non-slashed url, then relative
736736
// links like ../.. should be able

0 commit comments

Comments
 (0)