improve wordsFromCamel correctness (#3621)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
a4e1d026ea
commit
84957b0e88
1 changed files with 2 additions and 1 deletions
|
|
@ -21,7 +21,8 @@ import { moment } from "@webpack/common";
|
|||
// Utils for readable text transformations eg: `toTitle(fromKebab())`
|
||||
|
||||
// Case style to words
|
||||
export const wordsFromCamel = (text: string) => text.split(/(?=[A-Z])/).map(w => w.toLowerCase());
|
||||
export const wordsFromCamel = (text: string) =>
|
||||
text.split(/(?=[A-Z][a-z])|(?<=[a-z])(?=[A-Z])/).map(w => /^[A-Z]{2,}$/.test(w) ? w : w.toLowerCase());
|
||||
export const wordsFromSnake = (text: string) => text.toLowerCase().split("_");
|
||||
export const wordsFromKebab = (text: string) => text.toLowerCase().split("-");
|
||||
export const wordsFromPascal = (text: string) => text.split(/(?=[A-Z])/).map(w => w.toLowerCase());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue