use native path

This commit is contained in:
harttle
2016-11-06 17:20:03 +08:00
parent a82e50e1ab
commit fd2df81f9c
6 changed files with 16 additions and 40 deletions
-14
View File
@@ -14,21 +14,7 @@ function statFileAsync(path) {
});
};
function pathResolve(root, path) {
if (path[0] == '/') return path;
var arr = root.split('/').concat(path.split('/'));
var result = [];
arr.forEach(function(slug) {
if (slug == '..') result.pop();
else if (!slug || slug == '.');
else result.push(slug);
});
return '/' + result.join('/');
}
module.exports = {
readFileAsync,
pathResolve,
statFileAsync
};