Skip to content

Commit f840bc8

Browse files
lpincaFishrock123
authored andcommitted
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>
1 parent 6e3db28 commit f840bc8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ Url.prototype.resolveObject = function(relative) {
847847
// strip single dots, resolve double dots to parent dir
848848
// if the path tries to go above the root, `up` ends up > 0
849849
var up = 0;
850-
for (var i = srcPath.length; i >= 0; i--) {
850+
for (var i = srcPath.length - 1; i >= 0; i--) {
851851
last = srcPath[i];
852852
if (last === '.') {
853853
spliceOne(srcPath, i);

0 commit comments

Comments
 (0)