// find the first instance of any hostEndingChars
var hostEnd = -1;
- for (var i = 0; i < hostEndingChars.length; i++) {
- var hec = rest.indexOf(hostEndingChars[i]);
+ for (let i = 0; i < hostEndingChars.length; i++) {
+ const hec = rest.indexOf(hostEndingChars[i]);
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
hostEnd = hec;
}
// the host is the remaining to the left of the first non-host char
hostEnd = -1;
- for (var i = 0; i < nonHostChars.length; i++) {
- var hec = rest.indexOf(nonHostChars[i]);
+ for (let i = 0; i < nonHostChars.length; i++) {
+ const hec = rest.indexOf(nonHostChars[i]);
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
hostEnd = hec;
}
// validate a little.
if (!ipv6Hostname) {
var hostparts = this.hostname.split(/\./);
- for (var i = 0, l = hostparts.length; i < l; i++) {
+ for (let i = 0, l = hostparts.length; i < l; i++) {
var part = hostparts[i];
if (!part) continue;
if (!part.match(hostnamePartPattern)) {
var newpart = '';
- for (var j = 0, k = part.length; j < k; j++) {
+ for (let j = 0, k = part.length; j < k; j++) {
if (part.charCodeAt(j) > 127) {
// we replace non-ASCII char with a temporary placeholder
// we need this to make sure size of hostname is not
// First, make 100% sure that any "autoEscape" chars get
// escaped, even if encodeURIComponent doesn't think they
// need to be.
- for (var i = 0, l = autoEscape.length; i < l; i++) {
+ for (let i = 0, l = autoEscape.length; i < l; i++) {
var ae = autoEscape[i];
if (rest.indexOf(ae) === -1)
continue;
//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;
}
if (!relative.host &&
!/^file:?$/.test(relative.protocol) &&
!hostlessProtocol[relative.protocol]) {
- var relPath = (relative.pathname || '').split('/');
+ const relPath = (relative.pathname || '').split('/');
while (relPath.length && !(relative.host = relPath.shift()));
if (!relative.host) relative.host = '';
if (!relative.hostname) relative.hostname = '';
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('/') || [];
+ let srcPath = result.pathname && result.pathname.split('/') || [];
+ const relPath = relative.pathname && relative.pathname.split('/') || [];
const psychotic = result.protocol && !slashedProtocol[result.protocol];
// if the url is a non-slashed url, then relative
//occasionally the auth can get stuck only in host
//this especially happens in cases like
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost = result.host && result.host.indexOf('@') > 0 ?
+ const authInHost = result.host && result.host.indexOf('@') > 0 ?
result.host.split('@') : false;
if (authInHost) {
result.auth = authInHost.shift();
// strip single dots, resolve double dots to parent dir
// if the path tries to go above the root, `up` ends up > 0
var up = 0;
- for (var i = srcPath.length; i >= 0; i--) {
+ for (let i = srcPath.length; i >= 0; i--) {
last = srcPath[i];
if (last === '.') {
spliceOne(srcPath, i);
//occasionally the auth can get stuck only in host
//this especially happens in cases like
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost = result.host && result.host.indexOf('@') > 0 ?
+ const authInHost = result.host && result.host.indexOf('@') > 0 ?
result.host.split('@') : false;
if (authInHost) {
result.auth = authInHost.shift();