From 3fd009e848572ec0869c05dba89a3dafd3a04f06 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 21 Apr 2017 20:16:13 -0700 Subject: [PATCH] url: improve descriptiveness of identifier Change variable for protocols that do not always contain `//` to `noLeadingSlashes` so someone reading the code knows what it means. PR-URL: https://github.com/nodejs/node/pull/12579 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Timothy Gu Reviewed-By: Luigi Pinca Reviewed-By: Daijiro Wachi Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: James M Snell --- lib/url.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/url.js b/lib/url.js index 8579f2656b9eac..42d1b60aec0100 100644 --- a/lib/url.js +++ b/lib/url.js @@ -744,14 +744,14 @@ Url.prototype.resolveObject = function(relative) { var removeAllDots = mustEndAbs; var srcPath = result.pathname && result.pathname.split('/') || []; var relPath = relative.pathname && relative.pathname.split('/') || []; - var psychotic = result.protocol && !slashedProtocol[result.protocol]; + var noLeadingSlashes = result.protocol && !slashedProtocol[result.protocol]; // if the url is a non-slashed url, then relative // links like ../.. should be able // to crawl up to the hostname, as well. This is strange. // result.protocol has already been set by now. // Later on, put the first path part into the host field. - if (psychotic) { + if (noLeadingSlashes) { result.hostname = ''; result.port = null; if (result.host) { @@ -799,7 +799,7 @@ Url.prototype.resolveObject = function(relative) { // just pull out the search. // like href='?foo'. // Put this after the other two cases because it simplifies the booleans - if (psychotic) { + if (noLeadingSlashes) { result.hostname = result.host = srcPath.shift(); //occasionally the auth can get stuck only in host //this especially happens in cases like @@ -880,7 +880,7 @@ Url.prototype.resolveObject = function(relative) { (srcPath[0] && srcPath[0].charAt(0) === '/'); // put the host back - if (psychotic) { + if (noLeadingSlashes) { result.hostname = result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : ''; //occasionally the auth can get stuck only in host