mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
url: replaced slice with at
PR-URL: https://github.com/nodejs/node/pull/59181 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
1 parent
9df91e59e1
commit
8b29bbca76
1 file changed
+4
-2
+4
-2
@@ -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('');
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user