diff --git a/lib/common/utils.js b/lib/common/utils.js index 7e534cf62a..71aba7a4a7 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -150,8 +150,12 @@ export function flatRoutes(router, path = '', routes = []) { if (!r.path.includes(':') && !r.path.includes('*')) { /* istanbul ignore if */ if (r.children) { + if (path === '' && r.path === '/') { + routes.push('/') + } flatRoutes(r.children, path + r.path + '/', routes) } else { + path = path.replace(/^\/+$/, '/') routes.push((r.path === '' && path[path.length - 1] === '/' ? path.slice(0, -1) : path) + r.path) } }