diff --git a/src/utilities/transformName.ts b/src/utilities/transformName.ts index cb4a0695..a18d8441 100644 --- a/src/utilities/transformName.ts +++ b/src/utilities/transformName.ts @@ -8,7 +8,13 @@ const returnOrThrow = (convertedString: string, originalString: string, stringCa } const toCamelCase = (string: string): string => { - const convertedString: string = string.toLowerCase() + // check if the string is already in camel case + if (/^[a-z]+([A-Z][a-z]*)*$/.test(string)) { + // return the string as it is + return string; + } + // otherwise, apply the conversion logic + const convertedString: string = string.charAt(0).toLowerCase() + string.slice(1) .replace(/['"]/g, '') .replace(/([-_ ]){1,}/g, ' ') .replace(/\W+/g, ' ') @@ -19,6 +25,7 @@ const toCamelCase = (string: string): string => { return returnOrThrow(convertedString, string, 'camelCase') } + const toKebabCase = (string: string): string => { const convertedString: string = string.toLowerCase() .replace(/['"]/g, '')