Skip to content

fix(match): use pathMatch for the param of * routes #1995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(match): use fullPath for the param of * routes
Fix #1994
Combining an asterisk route (*) with props: true would result in an
error because the name of the param would be the number 0 making it an
invalid attribute + the fact that vue passes props as attributes
if they're not declared as props
  • Loading branch information
posva committed Apr 9, 2018
commit ad2a9884dba91e14b89d42170bad36f8eb89ee83
3 changes: 2 additions & 1 deletion src/create-matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ function matchRoute (
const key = regex.keys[i - 1]
const val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i]
if (key) {
params[key.name] = val
// Fix #1994: using * with props: true generates a param named 0
params[key.name || 'fullPath'] = val
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/route-matching.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
route.matched[0].path === '/asterisk/*' &&
route.fullPath === '/asterisk/foo' &&
JSON.stringify(route.params) === JSON.stringify({
0: 'foo'
'fullPath': '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({
0: 'foo/bar'
'fullPath': 'foo/bar'
})
)
}, null, '/asterisk/foo/bar')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/create-matcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createMatcher } from '../../../src/create-matcher'

const routes = [
{ path: '/', name: 'home', component: { name: 'home' }},
{ path: '/foo', name: 'foo', component: { name: 'foo' }},
{ path: '/foo', name: 'foo', component: { name: 'foo' }}
]

describe('Creating Matcher', function () {
Expand Down