Skip to content

Commit

Permalink
fix: Exception when randomUUID used without https (simpleangularcontr…
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjenni committed Aug 2, 2024
1 parent 3c29064 commit 1d7b4fb
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// #region Functions

/**
* create a guid with crypto library if availabe and a fallback to Math.Random implementation
*/
export function createGuid(): string {
if (typeof crypto !== undefined) {
if (typeof crypto !== undefined && crypto['randomUUID'] !== undefined) {
// return guid without hyphen
return crypto['randomUUID']().replace(/\-/gi, '');
} else {
Expand All @@ -13,3 +15,5 @@ export function createGuid(): string {
});
}
}

// #endregion Functions

0 comments on commit 1d7b4fb

Please sign in to comment.