Skip to content
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

no warn if pathMatch is empty (fix #3072) #3081

Merged
merged 1 commit into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/util/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export function fillParams (
return filler(params, { pretty: true })
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the if was necessary though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I revert it

warn(false, `missing param for ${routeMsg}: ${e.message}`)
// Fix #3072 no warn if `pathMatch` is string
warn(typeof params.pathMatch === 'string', `missing param for ${routeMsg}: ${e.message}`)
}
return ''
} finally {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/specs/create-matcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ describe('Creating Matcher', function () {
expect(path).toEqual('/error/some')
})

it('matches named catch-all route with empty pathMath param without warning', function () {
process.env.NODE_ENV = 'development'
match(
{ name: 'notFound', params: { pathMatch: '' }},
routes[0]
)
expect(console.warn).not.toHaveBeenCalled()
})

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