From 8647be9a7d6de09f79d3ff69d515ebef81082757 Mon Sep 17 00:00:00 2001 From: SwanandBhuskute Date: Thu, 28 Nov 2024 13:38:02 +0000 Subject: [PATCH] fixed cypress 4 --- src/Utils/utils.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 824d9733c43..19240c60a73 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -547,22 +547,20 @@ export const keysOf = (obj: T) => { // Capitalize the first letter of each word in a string, handling edge cases export const startCase = (str: string): string => { - if (!str || str.length == 0) return ""; - + if (!str || str.length === 0) return ""; return str - .toLowerCase() + .replace(/([A-Z])/g, " $1") + .replace(/[_-]+/g, " ") .replace(/\s+/g, " ") .trim() - .split(/[\s.'-]+/) - .map((word) => { - return word ? word[0].toUpperCase() + word.slice(1) : ""; - }) + .split(" ") + .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(" "); }; // Converts a string to camelCase format, first word - lowercase and each subsequent word - uppercase letter, with no spaces. -export const camelCase = (str: string) => { - if (!str || str.length == 0) return ""; +export const camelCase = (str: string): string => { + if (!str || str.length === 0) return ""; return str .trim() .replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ""))