From 816086e4c7a9fc549126ca0ac0fe05d26fa25ddb 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 5994f4534..1c2c149e9 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