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.
1 parent 3504c23 commit b30ffd6Copy full SHA for b30ffd6
src/utils.ts
@@ -48,10 +48,12 @@ type CamelToStartCase = (camelCaseString: string) => string;
48
49
export const camelToStartCase: CamelToStartCase = (camelCaseString) =>
50
camelCaseString
51
- // insert a space before all caps
52
- .replace(/([A-Z])/g, ' $1')
53
- // uppercase the first character
54
- .replace(/^./, (str) => str.toUpperCase());
+ // insert a space between lower & upper
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
+ // space before last upper in a sequence followed by lower
+ .replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
55
+ // uppercase the first letter
56
+ .replace(/([a-zA-Z])/, (str) => str.toUpperCase());
57
58
export const toKebabCase = (str: string): string =>
59
str
0 commit comments