Skip to content
Snippets Groups Projects
Verified Commit 47e78603 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

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.
parent f78fbc74
Branches
Tags
No related merge requests found
......@@ -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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment