Skip to content

Commit 14af144

Browse files
committed
router-link active inclusive match should ignore trailing slash (fix #826)
1 parent fb32ccb commit 14af144

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/util/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function isObjectEqual (a = {}, b = {}): boolean {
7676

7777
export function isIncludedRoute (current: Route, target: Route): boolean {
7878
return (
79-
current.path.indexOf(target.path) === 0 &&
79+
current.path.indexOf(target.path.replace(/\/$/, '')) === 0 &&
8080
(!target.hash || current.hash === target.hash) &&
8181
queryIncludes(current.query, target.query)
8282
)

test/unit/specs/route.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ describe('Route utils', () => {
3737
const a = { path: '/a/b' }
3838
const b = { path: '/a' }
3939
const c = { path: '/a/b/c' }
40+
const d = { path: '/a/b/' }
4041
expect(isIncludedRoute(a, b)).toBe(true)
4142
expect(isIncludedRoute(a, c)).toBe(false)
43+
expect(isIncludedRoute(a, d)).toBe(true)
4244
})
4345

4446
it('with hash', () => {

0 commit comments

Comments
 (0)