输入一个路由,输出一个匹配到的路由数组
export function urlToList(url) {
if(typeof url === 'object') return [];
const array = (url || '').split('/').filter(Boolean);
return array.map((item, index) => {
const path = array.slice(0, index + 1).join('/');
return `/${path}`;
});
}
pathname
urlToList(pathname)