From 6c93a18f089fff827f4bbcdb47bc8fe51536ba1c Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Thu, 18 Jun 2026 21:38:42 +0800 Subject: [PATCH] fix(config): align void.json revalidate key schema with runtime validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The editor JSON schema for routing.revalidate object keys used the pattern ^(/|\*), whose \* branch is unanchored — so it accepted keys like "*foo", "**", and "*/" that the runtime validator (config.ts) rejects (a key must be exactly "*" or start with "/"). Editors using $schema therefore showed no error for keys that fail at build time. Anchor the \* branch to ^(\/|\*$), matching the runtime contract and the already-correct routing.revalidateQueryAllowlist pattern. --- packages/void/schema.json | 2 +- packages/void/test/unit/config.test.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/void/schema.json b/packages/void/schema.json index 684196109..03e162fb6 100644 --- a/packages/void/schema.json +++ b/packages/void/schema.json @@ -154,7 +154,7 @@ { "type": "object", "patternProperties": { - "^(/|\\*)": { + "^(\\/|\\*$)": { "type": "number", "minimum": 0 } diff --git a/packages/void/test/unit/config.test.ts b/packages/void/test/unit/config.test.ts index d41f60fb7..9446cf6a2 100644 --- a/packages/void/test/unit/config.test.ts +++ b/packages/void/test/unit/config.test.ts @@ -629,6 +629,22 @@ describe('readConfig redirects', () => { expect(new Set(schemaEnum)).toEqual(VALID_REDIRECT_STATUSES); }); + it('schema.json revalidate key pattern matches runtime validation', () => { + const schema = JSON.parse(readFileSync(join(import.meta.dirname, '../../schema.json'), 'utf8')); + const objectForm = schema.properties.routing.properties.revalidate.oneOf.find( + (s: { type?: string }) => s.type === 'object', + ); + const keyPattern = new RegExp(Object.keys(objectForm.patternProperties)[0]); + + // Runtime (config.ts) accepts a key that is exactly "*" or starts with "/". + for (const key of ['*', '/x', '/docs/*']) { + expect(keyPattern.test(key)).toBe(true); + } + for (const key of ['*foo', '**', '*/', 'foo']) { + expect(keyPattern.test(key)).toBe(false); + } + }); + it('schema.json sourceDir pattern matches runtime validation', () => { const schema = JSON.parse(readFileSync(join(import.meta.dirname, '../../schema.json'), 'utf8')); const sourceDirPattern = new RegExp(schema.properties.sourceDir.pattern);