Fixed the issue of not being able to recognize differences in upper and lower case, resulting in duplication of labels

This commit is contained in:
PrinOrange
2024-01-06 16:18:34 +08:00
parent f35e2e49f4
commit e4c370ede5
2 changed files with 17 additions and 2 deletions

View File

@@ -56,3 +56,17 @@ export function isEmptyString(value: string | null | undefined): boolean {
}
return false;
}
/**
* Capitalizes the first letter of each word in a string.
*
* @param str - The input string.
* @returns The string with the first letter of each word capitalized.
*/
export function capitalizeFirstLetter(str: string) {
return str
.toLowerCase()
.split(" ")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(" ");
}