diff --git a/src/app/utils/generate-id-from-label/generate-id-from-label.ts b/src/app/utils/generate-id-from-label/generate-id-from-label.ts index 6efbcf2291..5b63476226 100644 --- a/src/app/utils/generate-id-from-label/generate-id-from-label.ts +++ b/src/app/utils/generate-id-from-label/generate-id-from-label.ts @@ -3,7 +3,11 @@ * This generates a camelCase string, so that it can be used as an id. * @param label The input string to be transformed */ -export function generateIdFromLabel(label: string) { +export function generateIdFromLabel(label: string): string | undefined { + if (typeof label !== "string") { + return undefined; + } + return label .replace(/[^a-zA-Z0-9\s]/g, "") .replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {