Skip to content

Commit

Permalink
refactor(match): use pathMatch instead of fullPath for unnamed params
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Apr 11, 2018
1 parent b505400 commit 5edc2ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/create-matcher.js
Expand Up @@ -190,7 +190,7 @@ function matchRoute (
const val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i]
if (key) {
// Fix #1994: using * with props: true generates a param named 0
params[key.name || 'fullPath'] = val
params[key.name || 'pathMatch'] = val
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/specs/route-matching.js
Expand Up @@ -83,7 +83,7 @@ module.exports = {
route.matched[0].path === '/asterisk/*' &&
route.fullPath === '/asterisk/foo' &&
JSON.stringify(route.params) === JSON.stringify({
'fullPath': 'foo'
pathMatch: 'foo'
})
)
}, null, '/asterisk/foo')
Expand All @@ -96,7 +96,7 @@ module.exports = {
route.matched[0].path === '/asterisk/*' &&
route.fullPath === '/asterisk/foo/bar' &&
JSON.stringify(route.params) === JSON.stringify({
'fullPath': 'foo/bar'
pathMatch: 'foo/bar'
})
)
}, null, '/asterisk/foo/bar')
Expand All @@ -120,7 +120,7 @@ module.exports = {
route.matched[0].path === '/optional-group/(foo/)?bar' &&
route.fullPath === '/optional-group/foo/bar' &&
JSON.stringify(route.params) === JSON.stringify({
0: 'foo/'
pathMatch: 'foo/'
})
)
}, null, '/optional-group/foo/bar')
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/create-matcher.spec.js
Expand Up @@ -34,8 +34,8 @@ describe('Creating Matcher', function () {
expect(console.warn).not.toHaveBeenCalled()
})

it('matches asterisk routes with fullName as the param', function () {
it('matches asterisk routes with a default param name', function () {
const { params } = match({ path: '/not-found' }, routes[0])
expect(params).toEqual({ fullPath: '/not-found' })
expect(params).toEqual({ pathMatch: '/not-found' })
})
})

0 comments on commit 5edc2ec

Please sign in to comment.