Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f88752d

Browse filesBrowse files
Connormihaaduh95
authored andcommitted
url: replaced slice with at
PR-URL: #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>
1 parent 8fd669c commit f88752d
Copy full SHA for f88752d

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎lib/url.js‎

Copy file name to clipboardExpand all lines: lib/url.js
+4-2Lines 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,
@@ -923,7 +925,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
923925
// If a url ENDs in . or .., then it must get a trailing slash.
924926
// however, if it ends in anything else non-slashy,
925927
// then it must NOT get a trailing slash.
926-
let last = srcPath.slice(-1)[0];
928+
let last = srcPath[srcPath.length - 1];
927929
const hasTrailingSlash = (
928930
((result.host || relative.host || srcPath.length > 1) &&
929931
(last === '.' || last === '..')) || last === '');
@@ -956,7 +958,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
956958
srcPath.unshift('');
957959
}
958960

959-
if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) {
961+
if (hasTrailingSlash && StringPrototypeAt(ArrayPrototypeJoin(srcPath, '/'), -1) !== '/') {
960962
srcPath.push('');
961963
}
962964

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.