You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
407 B
14 lines
407 B
// /userInfo/2144/id => ['/userInfo','/userInfo/2144,'/userInfo/2144/id']
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
export function urlToList(url) {
|
|
if (!url || url === '/') {
|
|
return ['/'];
|
|
}
|
|
|
|
var urlList = url.split('/').filter(function (i) {
|
|
return i;
|
|
});
|
|
return urlList.map(function (urlItem, index) {
|
|
return "/".concat(urlList.slice(0, index + 1).join('/'));
|
|
});
|
|
} |