From 84957b0e887fe1fa68bc6bf3325b44d1ba07a3f1 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Mon, 8 Sep 2025 22:49:24 +0000 Subject: [PATCH] improve `wordsFromCamel` correctness (#3621) Co-authored-by: V --- src/utils/text.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/text.ts b/src/utils/text.ts index 2e85af4e..a48c140d 100644 --- a/src/utils/text.ts +++ b/src/utils/text.ts @@ -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());