GeezerVison is showing github.com — url: replaced slice with at · nodejs/node@8b29bbc
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/url.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
22 | 22 | 'use strict'; |
23 | 23 |
|
24 | 24 | const { |
| 25 | + ArrayPrototypeJoin, |
25 | 26 | Boolean, |
26 | 27 | Int8Array, |
27 | 28 | ObjectAssign, |
28 | 29 | ObjectKeys, |
| 30 | + StringPrototypeAt, |
29 | 31 | StringPrototypeCharCodeAt, |
30 | 32 | StringPrototypeIndexOf, |
31 | 33 | StringPrototypeReplaceAll, |
@@ -923,7 +925,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { |
923 | 925 | // If a url ENDs in . or .., then it must get a trailing slash. |
924 | 926 | // however, if it ends in anything else non-slashy, |
925 | 927 | // then it must NOT get a trailing slash. |
926 | | - let last = srcPath.slice(-1)[0]; |
| 928 | + let last = srcPath[srcPath.length - 1]; |
927 | 929 | const hasTrailingSlash = ( |
928 | 930 | ((result.host || relative.host || srcPath.length > 1) && |
929 | 931 | (last === '.' || last === '..')) || last === ''); |
@@ -956,7 +958,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { |
956 | 958 | srcPath.unshift(''); |
957 | 959 | } |
958 | 960 |
|
959 | | - if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) { |
| 961 | + if (hasTrailingSlash && StringPrototypeAt(ArrayPrototypeJoin(srcPath, '/'), -1) !== '/') { |
960 | 962 | srcPath.push(''); |
961 | 963 | } |
962 | 964 |
|
|