Skip to content

Commit

Permalink
url: fix lint and deopt issues
Browse files Browse the repository at this point in the history
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 <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
mscdex authored and rvagg committed Feb 21, 2016
1 parent 729ad75 commit 4727470
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
var end = -1;
var rest = '';
var lastPos = 0;
for (var i = 0, inWs = false, split = false; i < url.length; ++i) {
var code = url.charCodeAt(i);
var i = 0;
for (var inWs = false, split = false; i < url.length; ++i) {
const code = url.charCodeAt(i);

// Find first and last non-whitespace characters for trimming
var isWs = code === 32/* */ ||
code === 9/*\t*/ ||
code === 13/*\r*/ ||
code === 10/*\n*/ ||
code === 12/*\f*/ ||
code === 160/*\u00A0*/ ||
code === 65279/*\uFEFF*/;
const isWs = code === 32/* */ ||
code === 9/*\t*/ ||
code === 13/*\r*/ ||
code === 10/*\n*/ ||
code === 12/*\f*/ ||
code === 160/*\u00A0*/ ||
code === 65279/*\uFEFF*/;
if (start === -1) {
if (isWs)
continue;
Expand Down Expand Up @@ -153,7 +154,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {

if (!slashesDenoteHost && !hasHash) {
// Try fast path regexp
var simplePath = simplePathPattern.exec(rest);
const simplePath = simplePathPattern.exec(rest);
if (simplePath) {
this.path = rest;
this.href = rest;
Expand Down Expand Up @@ -215,7 +216,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
var hostEnd = -1;
var atSign = -1;
var nonHost = -1;
for (var i = 0; i < rest.length; ++i) {
for (i = 0; i < rest.length; ++i) {
switch (rest.charCodeAt(i)) {
case 9: // '\t'
case 10: // '\n'
Expand Down Expand Up @@ -255,7 +256,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
if (hostEnd !== -1)
break;
}
var start = 0;
start = 0;
if (atSign !== -1) {
this.auth = decodeURIComponent(rest.slice(0, atSign));
start = atSign + 1;
Expand Down Expand Up @@ -284,9 +285,8 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
hostname.charCodeAt(hostname.length - 1) === 93/*]*/;

// validate a little.
var result;
if (!ipv6Hostname) {
result = validateHostname(this, rest, hostname);
const result = validateHostname(this, rest, hostname);
if (result !== undefined)
rest = result;
}
Expand Down Expand Up @@ -326,15 +326,15 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
// First, make 100% sure that any "autoEscape" chars get
// escaped, even if encodeURIComponent doesn't think they
// need to be.
result = autoEscapeStr(rest);
const result = autoEscapeStr(rest);
if (result !== undefined)
rest = result;
}

var questionIdx = -1;
var hashIdx = -1;
for (var i = 0; i < rest.length; ++i) {
var code = rest.charCodeAt(i);
for (i = 0; i < rest.length; ++i) {
const code = rest.charCodeAt(i);
if (code === 35/*#*/) {
this.hash = rest.slice(i);
hashIdx = i;
Expand Down Expand Up @@ -378,8 +378,8 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {

// to support http.request
if (this.pathname || this.search) {
var p = this.pathname || '';
var s = this.search || '';
const p = this.pathname || '';
const s = this.search || '';
this.path = p + s;
}

Expand Down Expand Up @@ -720,17 +720,17 @@ Url.prototype.resolveObject = function(relative) {
return result;
}

const isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
const isRelAbs = (
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
var isRelAbs = (
relative.host ||
relative.pathname && relative.pathname.charAt(0) === '/'
);
var mustEndAbs = (isRelAbs || isSourceAbs ||
(result.host && relative.pathname));
const removeAllDots = mustEndAbs;
var removeAllDots = mustEndAbs;
var srcPath = result.pathname && result.pathname.split('/') || [];
const relPath = relative.pathname && relative.pathname.split('/') || [];
const psychotic = result.protocol && !slashedProtocol[result.protocol];
var relPath = relative.pathname && relative.pathname.split('/') || [];
var psychotic = result.protocol && !slashedProtocol[result.protocol];

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

0 comments on commit 4727470

Please sign in to comment.