Skip to content

Commit

Permalink
fix: suppress warning if pathMatch is empty (#3081)
Browse files Browse the repository at this point in the history
Fix #3072
  • Loading branch information
yinm authored and posva committed Dec 30, 2019
1 parent 161b985 commit ddc6bc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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') {
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

0 comments on commit ddc6bc7

Please sign in to comment.