Skip to content

Commit 1442023

Browse files
authored
url: replaced slice with at
PR-URL: #59181 Reviewed-By: Jordan Harband <[email protected]> Reviewed-By: Zeyu "Alex" Yang <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 85db70b commit 1442023

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/url.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
'use strict';
2323

2424
const {
25+
ArrayPrototypeJoin,
2526
Boolean,
2627
Int8Array,
2728
ObjectAssign,
2829
ObjectKeys,
30+
StringPrototypeAt,
2931
StringPrototypeCharCodeAt,
3032
StringPrototypeIndexOf,
3133
StringPrototypeReplaceAll,
@@ -919,7 +921,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
919921
// If a url ENDs in . or .., then it must get a trailing slash.
920922
// however, if it ends in anything else non-slashy,
921923
// then it must NOT get a trailing slash.
922-
let last = srcPath.slice(-1)[0];
924+
let last = srcPath[srcPath.length - 1];
923925
const hasTrailingSlash = (
924926
((result.host || relative.host || srcPath.length > 1) &&
925927
(last === '.' || last === '..')) || last === '');
@@ -952,7 +954,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
952954
srcPath.unshift('');
953955
}
954956

955-
if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) {
957+
if (hasTrailingSlash && StringPrototypeAt(ArrayPrototypeJoin(srcPath, '/'), -1) !== '/') {
956958
srcPath.push('');
957959
}
958960

0 commit comments

Comments
 (0)