Skip to content

Commit 99f3f91

Browse files
Fix Titlecase function
1 parent 41e7ec0 commit 99f3f91

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

apps/frontend/src/utilities/data-formatters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export const sortDescByKey = (array, key) => {
129129
};
130130

131131
export const titleCase = (str: string | undefined) => {
132-
return str && typeof str === 'string' ? str[0].toUpperCase() + str.substring(1).toLowerCase() : '';
132+
if (!str || typeof str !== 'string') return '';
133+
return str.toLowerCase().replace(/\b\w/g, (char) => char.toUpperCase());
133134
};
134135

135136
export const copyTextToClipboard = (textToCopy: string | undefined) => {

0 commit comments

Comments
 (0)