Skip to content

Commit

Permalink
url: fix off-by-one error in loop handling dots
Browse files Browse the repository at this point in the history
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 14, 2016
1 parent 6e3db28 commit f840bc8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f840bc8

Please sign in to comment.