We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
pascalCaseToKebabCase
1 parent c909407 commit d66e100Copy full SHA for d66e100
src/utils/string-utils.ts
@@ -21,5 +21,8 @@ export function normalCaseToKebabCase(text: string) {
21
22
/** e.g. 'PascalCase' -> 'pascal-case' */
23
export function pascalCaseToKebabCase(text: string) {
24
- return normalCaseToKebabCase(text);
+ return text
25
+ .replace(/([a-z])([A-Z])/g, '$1-$2') // Inserts a hyphen between lowercase and uppercase letters
26
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // Handles cases like 'HTMLParser'
27
+ .toLowerCase(); // Converts the entire string to lowercase
28
}
0 commit comments