fix(CleanChannelName): trim repeated decoration separators (#1225)

This commit is contained in:
Mufaro 2026-07-05 16:54:21 +02:00 • committed by GitHub
parent 55e29f986b
commit 3f79fb55c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,13 +20,15 @@ const ORIGINAL_NAME = Symbol("cleanChannelName.original");
let editingChannelId: string | null = null;
function computeClean(name: string, type: number): string {
const separator = [2, 4].includes(type) ? " " : "-";
const cleaned = name
.normalize("NFKC")
.replace(/[ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ]/g, m => SMALL_CAPS[m])
.replace(/[^ -~]?\p{Extended_Pictographic}[^ -~]?/ug, "")
.replace(/-?[^\p{Letter} -~]-?/ug, [2, 4].includes(type) ? " " : "-")
.replace(/(^-|-$)/g, "")
.replace(/-+/g, "-");
.replace(/-?\|-?/g, separator)
.replace(/-?[^\p{Letter} -~]-?/ug, separator)
.replace(/-+/g, "-")
.replace(/(^-|-$)/g, "");
return cleaned || name;
}