Skip to content

Commit de3787c

Browse files
committed
url: use primordials for safe method
1 parent 19d61fc commit de3787c

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,6 +22,8 @@
2222
'use strict';
2323

2424
const {
25+
ArrayPrototypeAt,
26+
ArrayPrototypeJoin,
2527
Boolean,
2628
Int8Array,
2729
ObjectAssign,
@@ -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.at(-1);
924+
let last = ArrayPrototypeAt(srcPath, -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('/').at(-1) !== '/')) {
957+
if (hasTrailingSlash && ArrayPrototypeAt(ArrayPrototypeJoin(srcPath,'/'), -1) !== '/')) {
956958
srcPath.push('');
957959
}
958960

0 commit comments

Comments
 (0)