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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
lpinca authored and MylesBorins committed Oct 26, 2016
1 parent 775c84e commit 389a6d2
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 @@ -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);
Expand Down

0 comments on commit 389a6d2

Please sign in to comment.