From 155c268cd01ff2054bdad92216e07dc7ba1803e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 12 Jan 2016 22:04:50 +0100 Subject: [PATCH] lib: fix style issues after eslint update With an indentation style of two spaces, it is not possible to indent multiline variable declarations by four spaces. Instead, the var keyword is used on every new line. Use const instead of var where applicable for changed lines. PR-URL: https://github.com/nodejs/io.js/pull/2286 Reviewed-By: Roman Reiss --- lib/_debugger.js | 112 +++++++++++++++++----------------- lib/_http_server.js | 2 +- lib/_tls_legacy.js | 16 ++--- lib/_tls_wrap.js | 14 ++--- lib/assert.js | 10 +-- lib/fs.js | 22 +++---- lib/internal/child_process.js | 14 ++--- lib/net.js | 20 +++--- lib/path.js | 68 ++++++++++----------- lib/querystring.js | 6 +- lib/readline.js | 4 +- lib/tls.js | 12 ++-- lib/url.js | 42 ++++++------- 13 files changed, 170 insertions(+), 172 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index ad7ee6295bee2a..cc4b92fd6a901c 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -25,8 +25,8 @@ exports.start = function(argv, stdin, stdout) { stdin = stdin || process.stdin; stdout = stdout || process.stdout; - var args = ['--debug-brk'].concat(argv), - interface_ = new Interface(stdin, stdout, args); + const args = ['--debug-brk'].concat(argv); + const interface_ = new Interface(stdin, stdout, args); stdin.resume(); @@ -197,8 +197,8 @@ Client.prototype._removeScript = function(desc) { Client.prototype._onResponse = function(res) { - var cb, - index = -1; + var cb; + var index = -1; this._reqCallbacks.some(function(fn, i) { if (fn.request_seq == res.body.request_seq) { @@ -295,11 +295,11 @@ Client.prototype.reqLookup = function(refs, cb) { }; Client.prototype.reqScopes = function(cb) { - var self = this, - req = { - command: 'scopes', - arguments: {} - }; + const self = this; + const req = { + command: 'scopes', + arguments: {} + }; cb = cb || function() {}; this.req(req, function(err, res) { @@ -525,8 +525,8 @@ Client.prototype.mirrorObject = function(handle, depth, cb) { return; } - var mirror, - waiting = 1; + var mirror; + var waiting = 1; if (handle.className == 'Array') { mirror = []; @@ -676,8 +676,8 @@ var helpMessage = 'Commands: ' + commands.map(function(group) { function SourceUnderline(sourceText, position, repl) { if (!sourceText) return ''; - var head = sourceText.slice(0, position), - tail = sourceText.slice(position); + const head = sourceText.slice(0, position); + var tail = sourceText.slice(position); // Colourize char if stdout supports colours if (repl.useColors) { @@ -697,8 +697,8 @@ function SourceInfo(body) { if (body.script) { if (body.script.name) { - var name = body.script.name, - dir = path.resolve() + '/'; + var name = body.script.name; + const dir = path.resolve() + '/'; // Change path to relative, if possible if (name.indexOf(dir) === 0) { @@ -969,8 +969,8 @@ Interface.prototype.controlEval = function(code, context, filename, callback) { Interface.prototype.debugEval = function(code, context, filename, callback) { if (!this.requireConnection()) return; - var self = this, - client = this.client; + const self = this; + const client = this.client; // Repl asked for scope variables if (code === '.scope') { @@ -1004,9 +1004,9 @@ Interface.prototype.debugEval = function(code, context, filename, callback) { // Adds spaces and prefix to number // maxN is a maximum number we should have space for function leftPad(n, prefix, maxN) { - var s = n.toString(), - nchars = Math.max(2, String(maxN).length) + 1, - nspaces = nchars - s.length - 1; + const s = n.toString(); + const nchars = Math.max(2, String(maxN).length) + 1; + const nspaces = nchars - s.length - 1; for (var i = 0; i < nspaces; i++) { prefix += ' '; @@ -1078,10 +1078,10 @@ Interface.prototype.list = function(delta) { delta || (delta = 5); - var self = this, - client = this.client, - from = client.currentSourceLine - delta + 1, - to = client.currentSourceLine + delta + 1; + const self = this; + const client = this.client; + const from = client.currentSourceLine - delta + 1; + const to = client.currentSourceLine + delta + 1; self.pause(); client.reqSource(from, to, function(err, res) { @@ -1096,12 +1096,12 @@ Interface.prototype.list = function(delta) { var lineno = res.fromLine + i + 1; if (lineno < from || lineno > to) continue; - var current = lineno == 1 + client.currentSourceLine, - breakpoint = client.breakpoints.some(function(bp) { - return (bp.scriptReq === client.currentScript || - bp.script === client.currentScript) && - bp.line == lineno; - }); + const current = lineno == 1 + client.currentSourceLine; + const breakpoint = client.breakpoints.some(function(bp) { + return (bp.scriptReq === client.currentScript || + bp.script === client.currentScript) && + bp.line == lineno; + }); if (lineno == 1) { // The first line needs to have the module wrapper filtered out of @@ -1139,8 +1139,8 @@ Interface.prototype.list = function(delta) { Interface.prototype.backtrace = function() { if (!this.requireConnection()) return; - var self = this, - client = this.client; + const self = this; + const client = this.client; self.pause(); client.fullTrace(function(err, bt) { @@ -1153,8 +1153,8 @@ Interface.prototype.backtrace = function() { if (bt.totalFrames == 0) { self.print('(empty stack)'); } else { - var trace = [], - firstFrameNative = bt.frames[0].script.isNative; + const trace = []; + const firstFrameNative = bt.frames[0].script.isNative; for (var i = 0; i < bt.frames.length; i++) { var frame = bt.frames[i]; @@ -1183,9 +1183,9 @@ Interface.prototype.backtrace = function() { Interface.prototype.scripts = function() { if (!this.requireConnection()) return; - var client = this.client, - displayNatives = arguments[0] || false, - scripts = []; + const client = this.client; + const displayNatives = arguments[0] || false; + const scripts = []; this.pause(); for (var id in client.scripts) { @@ -1323,9 +1323,9 @@ Interface.prototype.setBreakpoint = function(script, line, condition, silent) { if (!this.requireConnection()) return; - var self = this, - scriptId, - ambiguous; + const self = this; + var scriptId; + var ambiguous; // setBreakpoint() should insert breakpoint on current line if (script === undefined) { @@ -1429,10 +1429,10 @@ Interface.prototype.setBreakpoint = function(script, line, Interface.prototype.clearBreakpoint = function(script, line) { if (!this.requireConnection()) return; - var ambiguous, - breakpoint, - scriptId, - index; + var ambiguous; + var breakpoint; + var scriptId; + var index; this.client.breakpoints.some(function(bp, i) { if (bp.scriptId === script || @@ -1474,10 +1474,8 @@ Interface.prototype.clearBreakpoint = function(script, line) { return this.error('Breakpoint not found on line ' + line); } - var self = this, - req = { - breakpoint: breakpoint - }; + var self = this; + const req = {breakpoint}; self.pause(); self.client.clearBreakpoint(req, function(err, res) { @@ -1513,8 +1511,8 @@ Interface.prototype.breakpoints = function() { Interface.prototype.pause_ = function() { if (!this.requireConnection()) return; - var self = this, - cmd = 'process._debugPause();'; + const self = this; + const cmd = 'process._debugPause();'; this.pause(); this.client.reqFrameEval(cmd, NO_FRAME, function(err, res) { @@ -1621,11 +1619,11 @@ Interface.prototype.killChild = function() { // Spawns child process (and restores breakpoints) Interface.prototype.trySpawn = function(cb) { - var self = this, - breakpoints = this.breakpoints || [], - port = exports.port, - host = '127.0.0.1', - childArgs = this.args; + const self = this; + const breakpoints = this.breakpoints || []; + var port = exports.port; + var host = '127.0.0.1'; + var childArgs = this.args; this.killChild(); assert(!this.child); @@ -1676,8 +1674,8 @@ Interface.prototype.trySpawn = function(cb) { this.pause(); - var client = self.client = new Client(), - connectionAttempts = 0; + const client = self.client = new Client(); + var connectionAttempts = 0; client.once('ready', function() { self.stdout.write(' ok\n'); diff --git a/lib/_http_server.js b/lib/_http_server.js index e2221b759bd0c4..7473008a1e8c31 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -64,7 +64,7 @@ const STATUS_CODES = exports.STATUS_CODES = { 426 : 'Upgrade Required', // RFC 2817 428 : 'Precondition Required', // RFC 6585 429 : 'Too Many Requests', // RFC 6585 - 431 : 'Request Header Fields Too Large',// RFC 6585 + 431 : 'Request Header Fields Too Large', // RFC 6585 500 : 'Internal Server Error', 501 : 'Not Implemented', 502 : 'Bad Gateway', diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index 1d700c9218f538..159d60e9ae1011 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -224,9 +224,9 @@ CryptoStream.prototype._write = function write(data, encoding, cb) { CryptoStream.prototype._writePending = function writePending() { - var data = this._pending, - encoding = this._pendingEncoding, - cb = this._pendingCallback; + const data = this._pending; + const encoding = this._pendingEncoding; + const cb = this._pendingCallback; this._pending = null; this._pendingEncoding = ''; @@ -252,9 +252,9 @@ CryptoStream.prototype._read = function read(size) { out = this.pair.ssl.encOut; } - var bytesRead = 0, - start = this._buffer.offset, - last = start; + var bytesRead = 0; + const start = this._buffer.offset; + var last = start; do { assert(last === this._buffer.offset); var read = this._buffer.use(this.pair.ssl, out, size - bytesRead); @@ -604,8 +604,8 @@ function onhandshakedone() { function onclienthello(hello) { - var self = this, - once = false; + const self = this; + var once = false; this._resumingSession = true; function callback(err, session) { diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 5b3690696ece66..35d5ba3b381fe3 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -397,8 +397,8 @@ TLSSocket.prototype._init = function(socket, wrap) { // For clients, we will always have either a given ca list or be using // default one - var requestCert = !!options.requestCert || !options.isServer, - rejectUnauthorized = !!options.rejectUnauthorized; + const requestCert = !!options.requestCert || !options.isServer; + const rejectUnauthorized = !!options.rejectUnauthorized; this._requestCert = requestCert; this._rejectUnauthorized = rejectUnauthorized; @@ -494,8 +494,8 @@ TLSSocket.prototype._init = function(socket, wrap) { }; TLSSocket.prototype.renegotiate = function(options, callback) { - var requestCert = this._requestCert, - rejectUnauthorized = this._rejectUnauthorized; + var requestCert = this._requestCert; + var rejectUnauthorized = this._rejectUnauthorized; if (this.destroyed) return; @@ -966,9 +966,9 @@ exports.connect = function(/* [port, host], options, cb */) { var hostname = options.servername || options.host || (options.socket && options.socket._host) || - 'localhost', - NPN = {}, - context = tls.createSecureContext(options); + 'localhost'; + const NPN = {}; + const context = tls.createSecureContext(options); tls.convertNPNProtocols(options.NPNProtocols, NPN); var socket = new TLSSocket(options.socket, { diff --git a/lib/assert.js b/lib/assert.js index 3e52ab45f66127..928420521e03e3 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -198,8 +198,8 @@ function objEquiv(a, b, strict) { return a === b; if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false; - var aIsArgs = isArguments(a), - bIsArgs = isArguments(b); + const aIsArgs = isArguments(a); + const bIsArgs = isArguments(b); if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) return false; if (aIsArgs) { @@ -207,9 +207,9 @@ function objEquiv(a, b, strict) { b = pSlice.call(b); return _deepEqual(a, b, strict); } - var ka = Object.keys(a), - kb = Object.keys(b), - key, i; + const ka = Object.keys(a); + const kb = Object.keys(b); + var key, i; // having the same number of owned properties (keys incorporates // hasOwnProperty) if (ka.length !== kb.length) diff --git a/lib/fs.js b/lib/fs.js index 57e9220a149f28..81f8a3c3ddc1a7 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -552,8 +552,8 @@ fs.openSync = function(path, flags, mode) { fs.read = function(fd, buffer, offset, length, position, callback) { if (!(buffer instanceof Buffer)) { // legacy string interface (fd, length, position, encoding, callback) - var cb = arguments[4], - encoding = arguments[3]; + const cb = arguments[4]; + const encoding = arguments[3]; assertEncoding(encoding); @@ -1388,9 +1388,9 @@ fs.realpathSync = function realpathSync(p, cache) { return cache[p]; } - var original = p, - seenLinks = {}, - knownHard = {}; + const original = p; + const seenLinks = {}; + const knownHard = {}; // current character position in p var pos; @@ -1490,9 +1490,9 @@ fs.realpath = function realpath(p, cache, cb) { return process.nextTick(cb.bind(null, null, cache[p])); } - var original = p, - seenLinks = {}, - knownHard = {}; + const original = p; + const seenLinks = {}; + const knownHard = {}; // current character position in p var pos; @@ -1941,9 +1941,9 @@ util.inherits(SyncWriteStream, Stream); // Export Object.defineProperty(fs, 'SyncWriteStream', { - configurable: true, - writable: true, - value: SyncWriteStream + configurable: true, + writable: true, + value: SyncWriteStream }); SyncWriteStream.prototype.write = function(data, arg1, arg2) { diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index b4365fb8c067f7..ce4cd6496fd1d2 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -250,11 +250,11 @@ function getHandleWrapType(stream) { ChildProcess.prototype.spawn = function(options) { - var self = this, - ipc, - ipcFd, - // If no `stdio` option was given - use default - stdio = options.stdio || 'pipe'; + const self = this; + var ipc; + var ipcFd; + // If no `stdio` option was given - use default + var stdio = options.stdio || 'pipe'; stdio = _validateStdio(stdio, false); @@ -692,8 +692,8 @@ function handleMessage(target, message, handle) { function nop() { } function _validateStdio(stdio, sync) { - var ipc, - ipcFd; + var ipc; + var ipcFd; // Replace shortcut with an array if (typeof stdio === 'string') { diff --git a/lib/net.js b/lib/net.js index f778043572362e..049a13133ae046 100644 --- a/lib/net.js +++ b/lib/net.js @@ -722,10 +722,10 @@ function createWriteReq(req, handle, data, encoding) { Socket.prototype.__defineGetter__('bytesWritten', function() { - var bytes = this._bytesDispatched, - state = this._writableState, - data = this._pendingData, - encoding = this._pendingEncoding; + var bytes = this._bytesDispatched; + const state = this._writableState; + const data = this._pendingData; + const encoding = this._pendingEncoding; if (!state) return undefined; @@ -1132,8 +1132,7 @@ function _listen(handle, backlog) { return handle.listen(backlog || 511); } -var createServerHandle = exports._createServerHandle = - function(address, port, addressType, fd) { +function createServerHandle(address, port, addressType, fd) { var err = 0; // assign handle in listen, and clean up if bind or listen fails var handle; @@ -1189,6 +1188,7 @@ var createServerHandle = exports._createServerHandle = return handle; }; +exports._createServerHandle = createServerHandle; Server.prototype._listen2 = function(address, port, addressType, backlog, fd) { @@ -1444,8 +1444,8 @@ Server.prototype.getConnections = function(cb) { } // Poll slaves - var left = this._slaves.length, - total = this._connections; + var left = this._slaves.length; + var total = this._connections; function oncount(err, count) { if (err) { @@ -1487,8 +1487,8 @@ Server.prototype.close = function(cb) { } if (this._usingSlaves) { - var self = this, - left = this._slaves.length; + var self = this; + var left = this._slaves.length; // Increment connections to be sure that, even if all sockets will be closed // during polling of slaves, `close` event will be emitted only once. diff --git a/lib/path.js b/lib/path.js index 0c9c656e66c3a7..c867dac83b9aad 100644 --- a/lib/path.js +++ b/lib/path.js @@ -74,21 +74,21 @@ var win32 = {}; // Function to split a filename into [root, dir, basename, ext] function win32SplitPath(filename) { // Separate device+slash from tail - var result = splitDeviceRe.exec(filename), - device = (result[1] || '') + (result[2] || ''), - tail = result[3]; + const result = splitDeviceRe.exec(filename); + const device = (result[1] || '') + (result[2] || ''); + const tail = result[3]; // Split the tail into dir, basename and extension - var result2 = splitTailRe.exec(tail), - dir = result2[1], - basename = result2[2], - ext = result2[3]; + const result2 = splitTailRe.exec(tail); + const dir = result2[1]; + const basename = result2[2]; + const ext = result2[3]; return [device, dir, basename, ext]; } function win32StatPath(path) { - var result = splitDeviceRe.exec(path), - device = result[1] || '', - isUnc = !!device && device[1] !== ':'; + const result = splitDeviceRe.exec(path); + const device = result[1] || ''; + const isUnc = !!device && device[1] !== ':'; return { device, isUnc, @@ -103,9 +103,9 @@ function normalizeUNCRoot(device) { // path.resolve([from ...], to) win32.resolve = function() { - var resolvedDevice = '', - resolvedTail = '', - resolvedAbsolute = false; + var resolvedDevice = ''; + var resolvedTail = ''; + var resolvedAbsolute = false; for (var i = arguments.length - 1; i >= -1; i--) { var path; @@ -134,11 +134,11 @@ win32.resolve = function() { continue; } - var result = win32StatPath(path), - device = result.device, - isUnc = result.isUnc, - isAbsolute = result.isAbsolute, - tail = result.tail; + const result = win32StatPath(path); + const device = result.device; + var isUnc = result.isUnc; + const isAbsolute = result.isAbsolute; + const tail = result.tail; if (device && resolvedDevice && @@ -182,12 +182,12 @@ win32.resolve = function() { win32.normalize = function(path) { assertPath(path); - var result = win32StatPath(path), - device = result.device, - isUnc = result.isUnc, - isAbsolute = result.isAbsolute, - tail = result.tail, - trailingSlash = /[\\\/]$/.test(tail); + const result = win32StatPath(path); + var device = result.device; + const isUnc = result.isUnc; + const isAbsolute = result.isAbsolute; + var tail = result.tail; + const trailingSlash = /[\\\/]$/.test(tail); // Normalize the tail path tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\'); @@ -318,9 +318,9 @@ win32._makeLong = function(path) { win32.dirname = function(path) { - var result = win32SplitPath(path), - root = result[0], - dir = result[1]; + const result = win32SplitPath(path); + const root = result[0]; + var dir = result[1]; if (!root && !dir) { // No dirname whatsoever @@ -417,8 +417,8 @@ function posixSplitPath(filename) { // path.resolve([from ...], to) // posix version posix.resolve = function() { - var resolvedPath = '', - resolvedAbsolute = false; + var resolvedPath = ''; + var resolvedAbsolute = false; for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { var path = (i >= 0) ? arguments[i] : process.cwd(); @@ -449,8 +449,8 @@ posix.resolve = function() { posix.normalize = function(path) { assertPath(path); - var isAbsolute = posix.isAbsolute(path), - trailingSlash = path && path[path.length - 1] === '/'; + const isAbsolute = posix.isAbsolute(path); + const trailingSlash = path && path[path.length - 1] === '/'; // Normalize the path path = normalizeArray(path.split('/'), !isAbsolute).join('/'); @@ -527,9 +527,9 @@ posix._makeLong = function(path) { posix.dirname = function(path) { - var result = posixSplitPath(path), - root = result[0], - dir = result[1]; + const result = posixSplitPath(path); + const root = result[0]; + var dir = result[1]; if (!root && !dir) { // No dirname whatsoever diff --git a/lib/querystring.js b/lib/querystring.js index 40677ffb0f0859..5f8df93038921f 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -230,9 +230,9 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { var keys = []; for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - k, v; + const x = qs[i].replace(regexp, '%20'); + const idx = x.indexOf(eq); + var k, v; if (idx >= 0) { k = decodeStr(x.substring(0, idx), decode); diff --git a/lib/readline.js b/lib/readline.js index 0f9aabb2fec475..00d9f8984e6a71 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -379,8 +379,8 @@ Interface.prototype._tabComplete = function() { return; } - var completions = rv[0], - completeOn = rv[1]; // the text that was completed + const completions = rv[0]; + const completeOn = rv[1]; // the text that was completed if (completions && completions.length) { // Apply/show completions. if (completions.length === 1) { diff --git a/lib/tls.js b/lib/tls.js index 8bd9991d8746b2..aad17c9ef2d6a3 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -90,12 +90,12 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { return new RegExp('^' + re + '$', 'i'); } - var dnsNames = [], - uriNames = [], - ips = [], - matchCN = true, - valid = false, - reason = 'Unknown reason'; + var dnsNames = []; + var uriNames = []; + const ips = []; + var matchCN = true; + var valid = false; + var reason = 'Unknown reason'; // There're several names to perform check against: // CN and altnames in certificate extension diff --git a/lib/url.js b/lib/url.js index 6489d6327d0e29..7348eadb7a9c6e 100644 --- a/lib/url.js +++ b/lib/url.js @@ -93,11 +93,11 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { // Copy chrome, IE, opera backslash-handling behavior. // Back slashes before the query string get converted to forward slashes // See: https://code.google.com/p/chromium/issues/detail?id=25916 - var queryIndex = url.indexOf('?'), - splitter = - (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', - uSplit = url.split(splitter), - slashRegex = /\\/g; + const queryIndex = url.indexOf('?'); + const splitter = + (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#'; + const uSplit = url.split(splitter); + const slashRegex = /\\/g; uSplit[0] = uSplit[0].replace(slashRegex, '/'); url = uSplit.join(splitter); @@ -370,11 +370,11 @@ Url.prototype.format = function() { auth += '@'; } - var protocol = this.protocol || '', - pathname = this.pathname || '', - hash = this.hash || '', - host = false, - query = ''; + var protocol = this.protocol || ''; + var pathname = this.pathname || ''; + var hash = this.hash || ''; + var host = false; + var query = ''; if (this.host) { host = auth + this.host; @@ -525,17 +525,17 @@ Url.prototype.resolveObject = function(relative) { return result; } - var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), - isRelAbs = ( - relative.host || - relative.pathname && relative.pathname.charAt(0) === '/' - ), - mustEndAbs = (isRelAbs || isSourceAbs || - (result.host && relative.pathname)), - removeAllDots = mustEndAbs, - srcPath = result.pathname && result.pathname.split('/') || [], - relPath = relative.pathname && relative.pathname.split('/') || [], - psychotic = result.protocol && !slashedProtocol[result.protocol]; + const isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'); + const isRelAbs = ( + relative.host || + relative.pathname && relative.pathname.charAt(0) === '/' + ); + var mustEndAbs = (isRelAbs || isSourceAbs || + (result.host && relative.pathname)); + const removeAllDots = mustEndAbs; + var srcPath = result.pathname && result.pathname.split('/') || []; + var relPath = relative.pathname && relative.pathname.split('/') || []; + const psychotic = result.protocol && !slashedProtocol[result.protocol]; // if the url is a non-slashed url, then relative // links like ../.. should be able