From 1d7b4fb07dccdd5be807d9536970a82162ef6d4c Mon Sep 17 00:00:00 2001 From: Philipp Jenni Date: Wed, 31 Jul 2024 08:21:22 +0200 Subject: [PATCH] fix: Exception when randomUUID used without https (#103) / (#101) --- .../projects/sac-common/src/utilities/guid.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ch.jnetwork.sac-controls/projects/sac-common/src/utilities/guid.ts b/ch.jnetwork.sac-controls/projects/sac-common/src/utilities/guid.ts index a761fcc6b..768477067 100644 --- a/ch.jnetwork.sac-controls/projects/sac-common/src/utilities/guid.ts +++ b/ch.jnetwork.sac-controls/projects/sac-common/src/utilities/guid.ts @@ -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 { @@ -13,3 +15,5 @@ export function createGuid(): string { }); } } + +// #endregion Functions