fix(CleanChannelName): trim repeated decoration separators (#1225)
This commit is contained in:
parent
55e29f986b
commit
3f79fb55c1
1 changed files with 5 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue