File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { warn } from '../util'
2
+ const regexEscapeRE = / [ - . * + ? ^ $ { } ( ) | [ \] \/ \\ ] / g
2
3
3
4
// install v-link, which provides navigation support for
4
5
// HTML5 history mode
@@ -46,7 +47,9 @@ export default function (Vue) {
46
47
let router = this . vm . $route . router
47
48
let activeClass = router . _linkActiveClass
48
49
let exactClass = activeClass + '-exact'
49
- if ( path . indexOf ( dest ) === 0 && path !== '/' ) {
50
+ if ( this . activeRE &&
51
+ this . activeRE . test ( path ) &&
52
+ path !== '/' ) {
50
53
_ . addClass ( el , activeClass )
51
54
} else {
52
55
_ . removeClass ( el , activeClass )
@@ -60,6 +63,9 @@ export default function (Vue) {
60
63
61
64
update : function ( path ) {
62
65
this . destination = path
66
+ this . activeRE = path
67
+ ? new RegExp ( '^' + path . replace ( regexEscapeRE , '\\$&' ) + '\\b' )
68
+ : null
63
69
this . updateClasses ( this . vm . $route . path )
64
70
path = path || ''
65
71
let router = this . vm . $route . router
Original file line number Diff line number Diff line change @@ -240,7 +240,13 @@ describe('Core', function () {
240
240
nextTick ( function ( ) {
241
241
expect ( linkA . className ) . toBe ( '' )
242
242
expect ( linkB . className ) . toBe ( 'active' )
243
- done ( )
243
+ router . go ( '/bcd' )
244
+ nextTick ( function ( ) {
245
+ // #114 should not match
246
+ expect ( linkA . className ) . toBe ( '' )
247
+ expect ( linkB . className ) . toBe ( '' )
248
+ done ( )
249
+ } )
244
250
} )
245
251
} )
246
252
} )
You can’t perform that action at this time.
0 commit comments