1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 15:19:06 +00:00
This commit is contained in:
Michael An
2019-06-20 18:25:10 +08:00
parent eaca5e0584
commit a08a1e97e3

View File

@@ -881,14 +881,15 @@ export const Utils = {
},
pathNormalize: function(originalPath) {
let newPath = originalPath.split('/');
for (let i = 0; i < newPath.length; i++) {
if (newPath[i] === '.' || newPath[i] === '') {
newPath.splice(i, 1);
i--;
} else if (newPath[i] === '..') {
newPath.splice(i - 1, 2);
i = i - 2;
let oldPath = originalPath.split('/');
let newPath = [];
for (let i = 0; i < oldPath.length; i++) {
if (oldPath[i] === '.' || oldPath[i] === '') {
continue;
} else if (oldPath[i] === '..') {
newPath.pop();
} else {
newPath.push(oldPath[i]);
}
}
return newPath.join('/');