@@ -13,6 +13,8 @@ import { HashHistory } from './history/hash'
1313import { HTML5History } from './history/html5'
1414import { AbstractHistory } from './history/abstract'
1515
16+ import type { Matcher } from './create-matcher'
17+
1618export default class VueRouter {
1719 static install : ( ) => void ;
1820 static version : string ;
@@ -24,7 +26,7 @@ export default class VueRouter {
2426 options : RouterOptions ;
2527 mode : string ;
2628 history : HashHistory | HTML5History | AbstractHistory ;
27- match : Matcher ;
29+ matcher : Matcher ;
2830 fallback : boolean ;
2931 beforeHooks : Array < ?NavigationGuard > ;
3032 afterHooks : Array < ?( ( to : Route , from : Route ) => any ) > ;
@@ -35,7 +37,7 @@ export default class VueRouter {
3537 this . options = options
3638 this . beforeHooks = [ ]
3739 this . afterHooks = [ ]
38- this . match = createMatcher ( options . routes || [ ] )
40+ this . matcher = createMatcher ( options . routes || [ ] )
3941
4042 let mode = options . mode || 'hash'
4143 this . fallback = mode === 'history' && ! supportsPushState
@@ -64,6 +66,14 @@ export default class VueRouter {
6466 }
6567 }
6668
69+ match (
70+ raw : RawLocation ,
71+ current ?: Route ,
72+ redirectedFrom ?: Location
73+ ) : Route {
74+ return this . matcher . match ( raw , current , redirectedFrom )
75+ }
76+
6777 get currentRoute ( ) : ?Route {
6878 return this . history && this . history . current
6979 }
@@ -180,8 +190,7 @@ export default class VueRouter {
180190 }
181191
182192 addRoutes ( routes : Array < RouteConfig > ) {
183- routes = this . options . routes = ( this . options . routes || [ ] ) . concat ( routes )
184- this . match = createMatcher ( routes )
193+ this . matcher . addRoutes ( routes )
185194 if ( this . history . current !== START ) {
186195 this . history . transitionTo ( this . history . getCurrentLocation ( ) )
187196 }
0 commit comments