mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +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';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
ArrayPrototypeJoin,
|
||||||
Boolean,
|
Boolean,
|
||||||
Int8Array,
|
Int8Array,
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
|
StringPrototypeAt,
|
||||||
StringPrototypeCharCodeAt,
|
StringPrototypeCharCodeAt,
|
||||||
StringPrototypeIndexOf,
|
StringPrototypeIndexOf,
|
||||||
StringPrototypeReplaceAll,
|
StringPrototypeReplaceAll,
|
||||||
|
|
@ -919,7 +921,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
|
||||||
// If a url ENDs in . or .., then it must get a trailing slash.
|
// If a url ENDs in . or .., then it must get a trailing slash.
|
||||||
// however, if it ends in anything else non-slashy,
|
// however, if it ends in anything else non-slashy,
|
||||||
// then it must NOT get a trailing slash.
|
// then it must NOT get a trailing slash.
|
||||||
let last = srcPath.slice(-1)[0];
|
let last = srcPath[srcPath.length - 1];
|
||||||
const hasTrailingSlash = (
|
const hasTrailingSlash = (
|
||||||
((result.host || relative.host || srcPath.length > 1) &&
|
((result.host || relative.host || srcPath.length > 1) &&
|
||||||
(last === '.' || last === '..')) || last === '');
|
(last === '.' || last === '..')) || last === '');
|
||||||
|
|
@ -952,7 +954,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
|
||||||
srcPath.unshift('');
|
srcPath.unshift('');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) {
|
if (hasTrailingSlash && StringPrototypeAt(ArrayPrototypeJoin(srcPath, '/'), -1) !== '/') {
|
||||||
srcPath.push('');
|
srcPath.push('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user