Skip to content

Commit

Permalink
fix: correctly extendRoutes
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jun 29, 2022
1 parent 757afca commit e8d22a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion playground/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Route, RouteParams, RouteParamsRaw } from '@vue-router'

const router = createRouter({
extendRoutes: (routes) => {
routes.find((r) => r.name === 'home')!.meta = {}
routes.find((r) => r.name === '/')!.meta = {}
return routes
},
history: createWebHistory(),
Expand Down
6 changes: 1 addition & 5 deletions src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,9 @@ export * from 'vue-router'
export function createRouter(options) {
const { extendRoutes } = options
if (typeof extendRoutes === 'function') {
routes = extendRoutes(routes) || routes
}
return _createRouter({
...options,
routes,
routes: typeof extendRoutes === 'function' ? extendRoutes(routes) : routes,
})
}
`
Expand Down

0 comments on commit e8d22a2

Please sign in to comment.