diff --git a/lib/url.js b/lib/url.js index 6331188bfef806..7248c9c277fa49 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, @@ -919,7 +921,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 === ''); @@ -952,7 +954,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { srcPath.unshift(''); } - if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) { + if (hasTrailingSlash && StringPrototypeAt(ArrayPrototypeJoin(srcPath, '/'), -1) !== '/') { srcPath.push(''); }