From 389a6d2cc203ee82cb20059e602aea8410b87a1a Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Tue, 6 Sep 2016 12:51:47 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/8420 Reviewed-By: Brian White Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- lib/url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/url.js b/lib/url.js index f2a627fbbeaf9e..e75b829ddff0f2 100644 --- a/lib/url.js +++ b/lib/url.js @@ -634,7 +634,7 @@ Url.prototype.resolveObject = function(relative) { // strip single dots, resolve double dots to parent dir // if the path tries to go above the root, `up` ends up > 0 var up = 0; - for (let i = srcPath.length; i >= 0; i--) { + for (var i = srcPath.length - 1; i >= 0; i--) { last = srcPath[i]; if (last === '.') { spliceOne(srcPath, i);