mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01: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:
parent
85db70b2cf
commit
1442023134
|
|
@ -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('');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user