1
1
/* @flow */
2
2
3
+ import type VueRouter from './index'
3
4
import { assert , warn } from './util/warn'
4
5
import { createRoute } from './util/route'
5
6
import { createRouteMap } from './create-route-map'
@@ -12,7 +13,10 @@ export type Matcher = {
12
13
addRoutes: ( routes : Array < RouteConfig > ) => void ;
13
14
} ;
14
15
15
- export function createMatcher ( routes : Array < RouteConfig > ) : Matcher {
16
+ export function createMatcher (
17
+ routes : Array < RouteConfig > ,
18
+ router : VueRouter
19
+ ) : Matcher {
16
20
const { pathMap, nameMap } = createRouteMap ( routes )
17
21
18
22
function addRoutes ( routes ) {
@@ -24,7 +28,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
24
28
currentRoute ?: Route ,
25
29
redirectedFrom ?: Location
26
30
) : Route {
27
- const location = normalizeLocation ( raw , currentRoute )
31
+ const location = normalizeLocation ( raw , currentRoute , false , router )
28
32
const { name } = location
29
33
30
34
if ( name ) {
@@ -70,7 +74,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
70
74
) : Route {
71
75
const originalRedirect = record . redirect
72
76
let redirect = typeof originalRedirect === 'function'
73
- ? originalRedirect ( createRoute ( record , location ) )
77
+ ? originalRedirect ( createRoute ( record , location , null , router ) )
74
78
: originalRedirect
75
79
76
80
if ( typeof redirect === 'string' ) {
@@ -156,7 +160,7 @@ export function createMatcher (routes: Array<RouteConfig>): Matcher {
156
160
if ( record && record . matchAs ) {
157
161
return alias ( record , location , record . matchAs )
158
162
}
159
- return createRoute ( record , location , redirectedFrom )
163
+ return createRoute ( record , location , redirectedFrom , router )
160
164
}
161
165
162
166
return {
0 commit comments