-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
/**
* @param {string} path
* @return {string}
*/
var simplifyPath = function(path) {
let pathArr = path.split("/");
let resultArr = [];
for(let i =0; i< pathArr.length;i++){
if(pathArr[i]==".."){
if(resultArr.length>0){
resultArr.pop();
}
}else if(pathArr[i]!="." && pathArr[i]!=""){
resultArr.push(pathArr[i])
}
}
return "/"+resultArr.join("/")
};
Metadata
Metadata
Assignees
Labels
No labels

