1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

optimized code

This commit is contained in:
shanshuirenjia
2018-12-17 22:34:54 +08:00
parent 5836e40712
commit 93b619899f
2 changed files with 19 additions and 11 deletions

View File

@@ -170,6 +170,24 @@ export const Utils = {
return filePath.slice(lastIndex+1);
},
/**
* input:
* eg: /
* ../abc/abc/
* ../abc/bc
* output(return):
* eg: /
* abc
* bc
*/
getFolderName: function(path) {
if (path === '/') {
return path;
}
path = path[path.length - 1] !== '/' ? path : path.slice(0, path.length -2);
return path.slice(path.lastIndexOf('/') + 1);
},
/*
return dirname of a path.
if path is '/', return '/'.