diff --git a/lib/url.js b/lib/url.js index f059da38ef8..3e562aec178 100644 --- a/lib/url.js +++ b/lib/url.js @@ -22,10 +22,12 @@ 'use strict'; const { + ArrayPrototypeJoin, Boolean, Int8Array, ObjectAssign, ObjectKeys, + StringPrototypeAt, StringPrototypeCharCodeAt, StringPrototypeIndexOf, StringPrototypeReplaceAll, @@ -923,7 +925,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { // If a url ENDs in . or .., then it must get a trailing slash. // however, if it ends in anything else non-slashy, // then it must NOT get a trailing slash. - let last = srcPath.slice(-1)[0]; + let last = srcPath[srcPath.length - 1]; const hasTrailingSlash = ( ((result.host || relative.host || srcPath.length > 1) && (last === '.' || last === '..')) || last === ''); @@ -956,7 +958,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { srcPath.unshift(''); } - if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) { + if (hasTrailingSlash && StringPrototypeAt(ArrayPrototypeJoin(srcPath, '/'), -1) !== '/') { srcPath.push(''); }