Skip to content

Commit aac5049

Browse files
committed
fix: no warn if pathMatch is empty
1 parent 479510b commit aac5049

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: src/util/params.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export function fillParams (
2424

2525
return filler(params, { pretty: true })
2626
} catch (e) {
27-
if (process.env.NODE_ENV !== 'production') {
27+
if (
28+
process.env.NODE_ENV !== 'production' &&
29+
params.pathMatch !== '' // Fix #3072 no warn if `pathMatch` is empty
30+
) {
2831
warn(false, `missing param for ${routeMsg}: ${e.message}`)
2932
}
3033
return ''

Diff for: 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)