From f75a9c405a6ec6a47883e25716efb87dc8bd088b Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Mon, 8 Apr 2024 20:23:44 -0700 Subject: [PATCH] Fix uuid regex --- deno/lib/types.ts | 2 +- src/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deno/lib/types.ts b/deno/lib/types.ts index d9c9945c3..715f207db 100644 --- a/deno/lib/types.ts +++ b/deno/lib/types.ts @@ -570,7 +570,7 @@ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/; // const uuidRegex = // /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; const uuidRegex = - /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; + /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i; const nanoidRegex = /^[a-z0-9_-]{21}$/i; // from https://stackoverflow.com/a/46181/1550155 // old version: too slow, didn't support unicode diff --git a/src/types.ts b/src/types.ts index 0f573f929..abd4eb9fa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -570,7 +570,7 @@ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/; // const uuidRegex = // /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; const uuidRegex = - /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; + /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i; const nanoidRegex = /^[a-z0-9_-]{21}$/i; // from https://stackoverflow.com/a/46181/1550155 // old version: too slow, didn't support unicode