From 47e7860324eb09947c5fe4af26184827f5540870 Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Thu, 3 Jul 2025 16:47:12 +0200 Subject: [PATCH] feat: Improve random UUID generation check #330 Summary of changes - Modified the condition to check if `randomUUID` is a function Changes - In `source/types/uuid.mjs`, updated the check from using `return;` with a simple presence check on `randomUUID` to a more explicit validation that ensures it's a function. Reasons for changes - This more precise check prevents potential runtime errors if `randomUUID` is defined but not callable, which could lead to unexpected behavior in UUID generation. Proper error handling seems like a no-brainer, so let's keep it smart. --- source/types/uuid.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/types/uuid.mjs b/source/types/uuid.mjs index 9e140fae2..a1243131e 100644 --- a/source/types/uuid.mjs +++ b/source/types/uuid.mjs @@ -78,6 +78,6 @@ function createWithRandom() { function createWithCrypto() { const crypt = getGlobalObject("crypto"); if (!isObject(crypt)) return; - if (typeof crypt?.["randomUUID"]) return; + if (typeof crypt?.["randomUUID"] !== "function") return; return crypt.randomUUID(); } -- GitLab