diff --git a/src/router/matchers.ts b/src/router/matchers.ts index a8652bc..2799c67 100644 --- a/src/router/matchers.ts +++ b/src/router/matchers.ts @@ -28,7 +28,7 @@ export class RouteMatchers extends Macroable { */ uuid() { return { - match: /^[0-9a-zA-F]{8}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{12}$/, + match: /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/, cast: (value: string) => value.toLowerCase(), } } diff --git a/tests/router/matchers.spec.ts b/tests/router/matchers.spec.ts index 166f669..b9197a7 100644 --- a/tests/router/matchers.spec.ts +++ b/tests/router/matchers.spec.ts @@ -35,6 +35,13 @@ test.group('Matchers', () => { assert.equal(uuid.cast(value.toUpperCase()), value) }) + test('uuid matcher rejects non-hex characters', ({ assert }) => { + const uuid = new RouteMatchers().uuid() + + assert.isFalse(uuid.match.test('zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz')) + assert.isFalse(uuid.match.test('gggggggg-gggg-gggg-gggg-gggggggggggg')) + }) + test('get matcher for a slug', ({ assert }) => { const slug = new RouteMatchers().slug()