11/* @flow */
22
3+ import type VueRouter from './index'
34import { assert , warn } from './util/warn'
45import { createRoute } from './util/route'
56import { createRouteMap } from './create-route-map'
@@ -12,7 +13,10 @@ export type Matcher = {
1213 addRoutes: ( routes : Array < RouteConfig > ) => void ;
1314} ;
1415
15- export function createMatcher ( routes : Array < RouteConfig > ) : Matcher {
16+ export function createMatcher (
17+ routes : Array < RouteConfig > ,
18+ router : VueRouter
19+ ) : Matcher {
1620 const { pathMap, nameMap } = createRouteMap ( routes )
1721
1822 function addRoutes ( routes ) {
@@ -24,7 +28,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
2428 currentRoute ?: Route ,
2529 redirectedFrom ?: Location
2630 ) : Route {
27- const location = normalizeLocation ( raw , currentRoute )
31+ const location = normalizeLocation ( raw , currentRoute , false , router )
2832 const { name } = location
2933
3034 if ( name ) {
@@ -70,7 +74,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
7074 ) : Route {
7175 const originalRedirect = record . redirect
7276 let redirect = typeof originalRedirect === 'function'
73- ? originalRedirect ( createRoute ( record , location ) )
77+ ? originalRedirect ( createRoute ( record , location , null , router ) )
7478 : originalRedirect
7579
7680 if ( typeof redirect === 'string' ) {
@@ -156,7 +160,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
156160 if ( record && record . matchAs ) {
157161 return alias ( record , location , record . matchAs )
158162 }
159- return createRoute ( record , location , redirectedFrom )
163+ return createRoute ( record , location , redirectedFrom , router )
160164 }
161165
162166 return {
0 commit comments