Skip to content

Commit fa7485b

Browse files
committed
fix(utils): reuse capitalize
1 parent d726b1f commit fa7485b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

packages/utils/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ export {
9797
export { isSemver, normalizeSemver, sortSemvers } from './lib/semver.js';
9898
export {
9999
camelCaseToKebabCase,
100-
kebabCaseToSentence,
101100
kebabCaseToCamelCase,
102-
formatToSentenceCase,
103101
capitalize,
102+
toSentenceCase,
103+
toTitleCase,
104104
} from './lib/case-conversions.js';
105105
export * from './lib/text-formats/index.js';
106106
export {

packages/utils/src/lib/case-conversions.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function toTitleCase(input: string): string {
7575

7676
// Capitalize first word or non-minor words
7777
if (index === 0 || !minorWords.has(word.toLowerCase())) {
78-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
78+
return capitalize(word);
7979
}
8080
return word.toLowerCase();
8181
})
@@ -103,7 +103,5 @@ export function toSentenceCase(input: string): string {
103103
}
104104

105105
export function capitalize<T extends string>(text: T): Capitalize<T> {
106-
return `${text.charAt(0).toLocaleUpperCase()}${text.slice(
107-
1,
108-
)}` as Capitalize<T>;
106+
return `${text.charAt(0).toLocaleUpperCase()}${text.slice(1).toLowerCase()}` as Capitalize<T>;
109107
}

0 commit comments

Comments
 (0)