UUID generation fixed

This commit is contained in:
AG
2025-11-28 18:20:22 +02:00
parent 245b8d3961
commit 4c632e164e
7 changed files with 26 additions and 10 deletions

10
utils/uuid.ts Normal file
View File

@@ -0,0 +1,10 @@
export const generateId = (): string => {
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
return crypto.randomUUID();
}
// Fallback for non-secure contexts
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
};