From 37a738c094e62f0452dfad3182865d0eb883b776 Mon Sep 17 00:00:00 2001 From: James Collins Date: Thu, 27 Apr 2023 13:31:02 +1000 Subject: [PATCH] fix toTitleCase --- resources/js/helpers/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/helpers/string.ts b/resources/js/helpers/string.ts index cae6292..6b60acf 100644 --- a/resources/js/helpers/string.ts +++ b/resources/js/helpers/string.ts @@ -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(); }); };