Skip to content

Commit e6dced2

Browse files
committed
v-link: allow trailing slash in exact match mode (close #183)
1 parent a76a0ce commit e6dced2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/directives/link.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { warn } from '../util'
2+
const trailingSlashRE = /\/$/
23
const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g
34

45
// install v-link, which provides navigation support for
@@ -100,7 +101,14 @@ export default function (Vue) {
100101
}
101102
// add new class
102103
if (this.exact) {
103-
if (path === dest) {
104+
if (
105+
dest === path ||
106+
(
107+
// also allow additional trailing slash
108+
dest.charAt(dest.length - 1) !== '/' &&
109+
dest === path.replace(trailingSlashRE, '')
110+
)
111+
) {
104112
_.addClass(el, activeClass)
105113
} else {
106114
_.removeClass(el, activeClass)

0 commit comments

Comments
 (0)