From: Eduardo San Martin Morote Date: Thu, 25 Aug 2022 11:49:51 +0000 (+0200) Subject: feat(warn): better wording X-Git-Tag: v4.1.5~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cc3093d0485cbd968ff096d1878bee40b7e47a9;p=thirdparty%2Fvuejs%2Frouter.git feat(warn): better wording #1530 --- diff --git a/packages/router/__tests__/warnings.spec.ts b/packages/router/__tests__/warnings.spec.ts index b6ac7608..0d2d9927 100644 --- a/packages/router/__tests__/warnings.spec.ts +++ b/packages/router/__tests__/warnings.spec.ts @@ -68,7 +68,7 @@ describe('warnings', () => { routes: [{ path: '/:p/:c', alias: ['/:p/c'], component }], }) expect( - 'Alias "/:p/c" and the original record: "/:p/:c" should have the exact same param named "c"' + 'Alias "/:p/c" and the original record: "/:p/:c" must have the exact same param named "c"' ).toHaveBeenWarned() }) @@ -90,7 +90,7 @@ describe('warnings', () => { ], }) expect( - `Absolute path "/:a/b" should have the exact same param named "b" as its parent "/:a/:b".` + `Absolute path "/:a/b" must have the exact same param named "b" as its parent "/:a/:b".` ).toHaveBeenWarned() }) @@ -100,7 +100,7 @@ describe('warnings', () => { routes: [{ path: '/:p/:c', alias: ['/:p/:c+'], component }], }) expect( - 'Alias "/:p/:c+" and the original record: "/:p/:c" should have the exact same param named "c"' + 'Alias "/:p/:c+" and the original record: "/:p/:c" must have the exact same param named "c"' ).toHaveBeenWarned() }) @@ -110,7 +110,7 @@ describe('warnings', () => { routes: [{ path: '/:p/c', alias: ['/:p/:c'], component }], }) expect( - 'Alias "/:p/:c" and the original record: "/:p/c" should have the exact same param named "c"' + 'Alias "/:p/:c" and the original record: "/:p/c" must have the exact same param named "c"' ).toHaveBeenWarned() }) @@ -139,7 +139,7 @@ describe('warnings', () => { it('warns if a non valid function is passed as a component', async () => { const Functional: FunctionalComponent = () => h('div', 'functional') - // Functional should have a displayName to avoid the warning + // Functional must have a displayName to avoid the warning const router = createRouter({ history: createMemoryHistory(), diff --git a/packages/router/src/matcher/index.ts b/packages/router/src/matcher/index.ts index bd922eb5..f2bf941b 100644 --- a/packages/router/src/matcher/index.ts +++ b/packages/router/src/matcher/index.ts @@ -449,13 +449,13 @@ function checkSameParams(a: RouteRecordMatcher, b: RouteRecordMatcher) { for (const key of a.keys) { if (!key.optional && !b.keys.find(isSameParam.bind(null, key))) return warn( - `Alias "${b.record.path}" and the original record: "${a.record.path}" should have the exact same param named "${key.name}"` + `Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"` ) } for (const key of b.keys) { if (!key.optional && !a.keys.find(isSameParam.bind(null, key))) return warn( - `Alias "${b.record.path}" and the original record: "${a.record.path}" should have the exact same param named "${key.name}"` + `Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"` ) } } @@ -491,7 +491,7 @@ function checkMissingParamsInAbsolutePath( for (const key of parent.keys) { if (!record.keys.find(isSameParam.bind(null, key))) return warn( - `Absolute path "${record.record.path}" should have the exact same param named "${key.name}" as its parent "${parent.record.path}".` + `Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".` ) } }