mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-08 16:56:09 +00:00
fix(shared): preserve unicode slug labels
Fixes #58932. Carries forward #58942 and #58995. Thanks @fengqing-git, @Starhappysh, and @koen666.
This commit is contained in:
@@ -51,23 +51,27 @@ export function normalizeCsvOrLooseStringList(value: unknown): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
function normalizeSlugInput(raw?: string | null) {
|
||||
return (normalizeOptionalLowercaseString(raw) ?? "").normalize("NFC");
|
||||
}
|
||||
|
||||
export function normalizeHyphenSlug(raw?: string | null) {
|
||||
const trimmed = normalizeOptionalLowercaseString(raw) ?? "";
|
||||
const trimmed = normalizeSlugInput(raw);
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
const dashed = trimmed.replace(/\s+/g, "-");
|
||||
const cleaned = dashed.replace(/[^a-z0-9#@._+-]+/g, "-");
|
||||
const cleaned = dashed.replace(/[^\p{L}\p{M}\p{N}#@._+-]+/gu, "-");
|
||||
return cleaned.replace(/-{2,}/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
||||
}
|
||||
|
||||
export function normalizeAtHashSlug(raw?: string | null) {
|
||||
const trimmed = normalizeOptionalLowercaseString(raw) ?? "";
|
||||
const trimmed = normalizeSlugInput(raw);
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
const withoutPrefix = trimmed.replace(/^[@#]+/, "");
|
||||
const dashed = withoutPrefix.replace(/[\s_]+/g, "-");
|
||||
const cleaned = dashed.replace(/[^a-z0-9-]+/g, "-");
|
||||
const cleaned = dashed.replace(/[^\p{L}\p{M}\p{N}-]+/gu, "-");
|
||||
return cleaned.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user