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 Jul 31, 2024
1 parent 9546c5e commit c072cc0
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 c072cc0

Please sign in to comment.