Permalink
Browse files

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 <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information...
lpinca authored and Fishrock123 committed Sep 6, 2016
1 parent 6e3db28 commit f840bc87d6ee27ef1418bd14c21117302749ed79
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/url.js
View
@@ -847,7 +847,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);

0 comments on commit f840bc8

Please sign in to comment.