From 9a70d4de0de9c5bc7bd54824e01f3aefcc9159da Mon Sep 17 00:00:00 2001 From: James Collins Date: Sat, 2 Sep 2023 19:59:26 +1000 Subject: [PATCH] bugfix --- resources/js/helpers/string.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/js/helpers/string.ts b/resources/js/helpers/string.ts index c4ae6d8..d37d1db 100644 --- a/resources/js/helpers/string.ts +++ b/resources/js/helpers/string.ts @@ -7,13 +7,15 @@ export const toTitleCase = (str: string): string => { // Replace underscores and hyphens with spaces str = str.replace(/[_-]+/g, " "); - // Replace "Cdn" with "CDN" - str = str.replace(/\bCdn\b/g, "CDN"); - // Capitalize the first letter of each word and make the rest lowercase - return str.replace(/\b\w+\b/g, (txt) => { + str = str.replace(/\b\w+\b/g, (txt) => { return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase(); }); + + // Replace "cdn" with "CDN" + str = str.replace(/\bCdn\b/gi, "CDN"); + + return str; }; /**