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:
authorAndreas Madsen <amwebdk@gmail.com>2013-01-08 21:22:04 +0400
committerisaacs <i@izs.me>2013-01-11 05:58:37 +0400
commitbb1c03989f8702e06072e6d9228b52661bf00ace (patch)
tree25c56928dee2659b3a482285bf422d6439fb1aa0 /lib/path.js
parentb916774255940c721df882b5b8ab63934891df99 (diff)
path: fix bugs related to paths with trailing slashes
Diffstat (limited to 'lib/path.js')
-rw-r--r--lib/path.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/path.js b/lib/path.js
index 0b24de299fc..980348e7d11 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -290,7 +290,17 @@ if (isWindows) {
// 'root' is just a slash, or nothing.
var splitPathRe =
/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/;
+ var trailingSlash = /\/+$/;
var splitPath = function(filename) {
+
+ // removes trailing slashes before spliting the path
+ var tail = trailingSlash.exec(filename);
+ if (tail) {
+ if (tail.index === 0) return ['/', '', '', ''];
+
+ filename = filename.slice(0, tail.index);
+ }
+
var result = splitPathRe.exec(filename);
return [result[1] || '', result[2] || '', result[3] || '', result[4] || ''];
};