fix toTitleCase

This commit is contained in:
2023-04-27 13:31:02 +10:00
parent bef4c3440b
commit 37a738c094

View File

@@ -5,7 +5,7 @@
* @returns {string} A string transformed to title case.
*/
export const toTitleCase = (str: string): string => {
return str.replace(/\b\w+\b/g, function (txt) {
return str.replace(/[_-]+/g, " ").replace(/\b\w+\b/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
});
};