Skip to content

Commit 1ee658f

Browse files
committed
fix: 修复 pathResolve 函数在 path 为空时返回 parentPath 的逻辑,避免拼接出错
1 parent 9ac6017 commit 1ee658f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/utils/routerHelper.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord
101101
if (!route.children && route.parentId == 0 && route.component) {
102102
data.component = Layout
103103
data.meta = {
104-
hidden: meta.hidden,
104+
hidden: meta.hidden
105105
}
106106
data.name = toCamelCase(route.path, true) + 'Parent'
107107
data.redirect = ''
@@ -170,8 +170,9 @@ const generateRoutePath = (parentPath: string, path: string) => {
170170
}
171171
export const pathResolve = (parentPath: string, path: string) => {
172172
if (isUrl(path)) return path
173-
const childPath = path.startsWith('/') || !path ? path : `/${path}`
174-
return `${parentPath}${childPath}`.replace(/\/\//g, '/')
173+
if (!path) return parentPath // 修复 path 为空时返回 parentPath,避免拼接出错 https://t.zsxq.com/QVr6b
174+
const childPath = path.startsWith('/') ? path : `/${path}`
175+
return `${parentPath}${childPath}`.replace(/\/+/g, '/')
175176
}
176177

177178
// 路由降级

0 commit comments

Comments
 (0)