Skip to content

Commit 389a6d2

Browse files
lpincaMylesBorins
authored andcommitted
url: fix off-by-one error in loop handling dots
Fixes an error where a loop, used to traverse an array of length `n`, ran `n + 1` times instead of `n`. PR-URL: #8420 Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 775c84e commit 389a6d2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ Url.prototype.resolveObject = function(relative) {
634634
// strip single dots, resolve double dots to parent dir
635635
// if the path tries to go above the root, `up` ends up > 0
636636
var up = 0;
637-
for (let i = srcPath.length; i >= 0; i--) {
637+
for (var i = srcPath.length - 1; i >= 0; i--) {
638638
last = srcPath[i];
639639
if (last === '.') {
640640
spliceOne(srcPath, i);

0 commit comments

Comments
 (0)