Browse Source

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 <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
v7.x
Luigi Pinca 8 years ago
committed by James M Snell
parent
commit
63493e1cb3
  1. 2
      lib/url.js

2
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);

Loading…
Cancel
Save