From 63493e1cb3d64dd0b7672039a05855ee6178b549 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 0e15811a6c2045..d9357268728985 100644 --- a/lib/url.js +++ b/lib/url.js @@ -852,7 +852,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 (var i = srcPath.length; i >= 0; i--) { + for (var i = srcPath.length - 1; i >= 0; i--) { last = srcPath[i]; if (last === '.') { spliceOne(srcPath, i);