Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2016-05-05 08:27:06 +0300
committerBrian White <mscdex@mscdex.net>2016-05-18 09:12:28 +0300
commitdfaa9c905530e30bd02d713c37546febb7446257 (patch)
tree2ec54a442fad4075035c5f5c82fccb6ee88ca7be /lib/path.js
parent2ccba1f9fa8e593d09f2f4f284e246e1f8bb6549 (diff)
path: fix basename() regressions
This commit fixes a regression in basename() for the case when a supplied extension name completely matches the resulting basename. Fixes: https://github.com/nodejs/node/issues/6587 PR-URL: https://github.com/nodejs/node/pull/6590 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'lib/path.js')
-rw-r--r--lib/path.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/path.js b/lib/path.js
index 0fbc715ea8c..5637b328c1d 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -855,8 +855,10 @@ const win32 = {
}
}
- if (end === -1)
- return '';
+ if (start === end)
+ end = firstNonSlashEnd;
+ else if (end === -1)
+ end = path.length;
return path.slice(start, end);
} else {
for (i = path.length - 1; i >= start; --i) {
@@ -1398,8 +1400,10 @@ const posix = {
}
}
- if (end === -1)
- return '';
+ if (start === end)
+ end = firstNonSlashEnd;
+ else if (end === -1)
+ end = path.length;
return path.slice(start, end);
} else {
for (i = path.length - 1; i >= 0; --i) {