Skip to content

Commit 784b367

Browse files
committed
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
1 parent a290ddf commit 784b367

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
@@ -852,7 +852,7 @@ Url.prototype.resolveObject = function(relative) {
852852
// strip single dots, resolve double dots to parent dir
853853
// if the path tries to go above the root, `up` ends up > 0
854854
var up = 0;
855-
for (var i = srcPath.length; i >= 0; i--) {
855+
for (var i = srcPath.length - 1; i >= 0; i--) {
856856
last = srcPath[i];
857857
if (last === '.') {
858858
spliceOne(srcPath, i);

0 commit comments

Comments
 (0)