Skip to content

Commit ddc6bc7

Browse files
yinmposva
authored andcommitted
fix: suppress warning if pathMatch is empty (#3081)
Fix #3072
1 parent 161b985 commit ddc6bc7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/util/params.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export function fillParams (
2525
return filler(params, { pretty: true })
2626
} catch (e) {
2727
if (process.env.NODE_ENV !== 'production') {
28-
warn(false, `missing param for ${routeMsg}: ${e.message}`)
28+
// Fix #3072 no warn if `pathMatch` is string
29+
warn(typeof params.pathMatch === 'string', `missing param for ${routeMsg}: ${e.message}`)
2930
}
3031
return ''
3132
} finally {

test/unit/specs/create-matcher.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ describe('Creating Matcher', function () {
7171
expect(path).toEqual('/error/some')
7272
})
7373

74+
it('matches named catch-all route with empty pathMath param without warning', function () {
75+
process.env.NODE_ENV = 'development'
76+
match(
77+
{ name: 'notFound', params: { pathMatch: '' }},
78+
routes[0]
79+
)
80+
expect(console.warn).not.toHaveBeenCalled()
81+
})
82+
7483
it('matches asterisk routes with a default param name', function () {
7584
const { params } = match({ path: '/not-found' }, routes[0])
7685
expect(params).toEqual({ pathMatch: '/not-found' })

0 commit comments

Comments
 (0)