Skip to content

Commit

Permalink
url: improve descriptiveness of identifier
Browse files Browse the repository at this point in the history
Change variable for protocols that do not always contain `//` to
`noLeadingSlashes` so someone reading the code knows what it means.

PR-URL: #12579
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and evanlucas committed May 2, 2017
1 parent 80ceb04 commit 539ffae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,14 +755,14 @@ Url.prototype.resolveObject = function resolveObject(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) {
Expand Down Expand Up @@ -810,7 +810,7 @@ Url.prototype.resolveObject = function resolveObject(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
Expand Down Expand Up @@ -891,7 +891,7 @@ Url.prototype.resolveObject = function resolveObject(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
Expand Down

0 comments on commit 539ffae

Please sign in to comment.