Skip to content

Commit

Permalink
Fixes jacobrask#124: Requires path separator in basepath
Browse files Browse the repository at this point in the history
By making sure the common path ends with a path separator, we know we end up with an actual valid base path.
  • Loading branch information
RonaldTreur committed Oct 28, 2014
1 parent 9f12e71 commit 3af86ac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/styledocco
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ if (optimist.argv.version != null) {
var commonprefix = function(arr) {
if (!arr.length) return null;
if (arr.length === 1) return arr[0];
return arr.reduce(function(res, cur) {
var prefix = arr.reduce(function(res, cur) {
while (res !== cur.slice(0, res.length)) {
res = res.slice(0, -1);
}
return res;
});
var lastSlash = prefix.lastIndexOf(path.sep);
return lastSlash === -1 ? prefix : prefix.substr(0, lastSlash+1);
};

var isArray = function(obj) {
Expand Down

0 comments on commit 3af86ac

Please sign in to comment.