Skip to content

Commit

Permalink
fix(Admin UI): prevent error generating ID when resetting label of field
Browse files Browse the repository at this point in the history
  • Loading branch information
sleidig committed Dec 19, 2024
1 parent 5e7c6e2 commit 156fe44
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 156fe44

Please sign in to comment.