From a08a1e97e31d02ab93aa033901d4ba5bd4f1c1e8 Mon Sep 17 00:00:00 2001 From: Michael An <1822852997@qq.com> Date: Thu, 20 Jun 2019 18:25:10 +0800 Subject: [PATCH] update --- frontend/src/utils/utils.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/src/utils/utils.js b/frontend/src/utils/utils.js index 7346ec0598..04479817e3 100644 --- a/frontend/src/utils/utils.js +++ b/frontend/src/utils/utils.js @@ -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('/');