diff --git a/lib/url.js b/lib/url.js index b6b5376c379a6c..4ec0ad3ee11d79 100644 --- a/lib/url.js +++ b/lib/url.js @@ -958,7 +958,8 @@ Url.prototype.resolveObject = function resolveObject(relative) { srcPath.unshift(''); } - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { + const srcPathSlashes = srcPath.join('/'); + if (hasTrailingSlash && (srcPathSlashes.substring(srcPathJoin.length - 1) !== '/')) { srcPath.push(''); } @@ -990,7 +991,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { result.pathname = null; result.path = null; } else { - result.pathname = srcPath.join('/'); + result.pathname = srcPathSlashes; } // To support request.http