Skip to content

Commit

Permalink
fix(text): use locale-independent letter case methods (#6016)
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-rowe committed Nov 22, 2024
1 parent a73ff94 commit 33c4a3b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion text/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export function splitToWords(input: string) {

export function capitalizeWord(word: string): string {
return word
? word?.[0]?.toLocaleUpperCase() + word.slice(1).toLocaleLowerCase()
? word?.[0]?.toUpperCase() + word.slice(1).toLowerCase()
: word;
}
2 changes: 1 addition & 1 deletion text/to_camel_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ import { capitalizeWord, splitToWords } from "./_util.ts";
export function toCamelCase(input: string): string {
input = input.trim();
const [first = "", ...rest] = splitToWords(input);
return [first.toLocaleLowerCase(), ...rest.map(capitalizeWord)].join("");
return [first.toLowerCase(), ...rest.map(capitalizeWord)].join("");
}
2 changes: 1 addition & 1 deletion text/to_kebab_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ import { splitToWords } from "./_util.ts";
*/
export function toKebabCase(input: string): string {
input = input.trim();
return splitToWords(input).join("-").toLocaleLowerCase();
return splitToWords(input).join("-").toLowerCase();
}
2 changes: 1 addition & 1 deletion text/to_snake_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ import { splitToWords } from "./_util.ts";
*/
export function toSnakeCase(input: string): string {
input = input.trim();
return splitToWords(input).join("_").toLocaleLowerCase();
return splitToWords(input).join("_").toLowerCase();
}
2 changes: 1 addition & 1 deletion text/unstable_to_constant_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ import { splitToWords } from "./_util.ts";
*/
export function toConstantCase(input: string): string {
input = input.trim();
return splitToWords(input).join("_").toLocaleUpperCase();
return splitToWords(input).join("_").toUpperCase();
}

0 comments on commit 33c4a3b

Please sign in to comment.