Ужесточение имен каналов и удаление legacy USER_PARAM для описания

This commit is contained in:
AidarKC
2026-05-08 19:06:58 +03:00
parent acdd6c928b
commit 4956ba7352
6 changed files with 34 additions and 344 deletions
+6 -21
View File
@@ -1,10 +1,10 @@
const MIN_LEN = 3;
const MAX_LEN = 32;
const ALLOWED_CHARS_RE = /^[\p{Script=Latin}\p{Script=Cyrillic}0-9 _-]+$/u;
const ALLOWED_CHARS_RE = /^[A-Za-z0-9_-]+$/;
export function normalizeChannelDisplayName(value) {
if (value == null) return '';
return String(value).trim().replace(/\s+/g, ' ');
return String(value).trim();
}
export function normalizeChannelDescription(value) {
@@ -16,24 +16,9 @@ export function toCanonicalChannelSlug(value) {
const normalized = normalizeChannelDisplayName(value);
if (!normalized) return '';
const lowered = normalized.toLowerCase().replace(/\u0451/g, '\u0435');
let out = '';
let pendingSeparator = false;
for (const ch of lowered) {
if (ch === ' ' || ch === '_' || ch === '-') {
pendingSeparator = out.length > 0;
continue;
}
if (!/[\p{Script=Latin}\p{Script=Cyrillic}0-9]/u.test(ch)) {
return '';
}
if (pendingSeparator && out.length > 0) out += '-';
out += ch;
pendingSeparator = false;
}
return out.replace(/-+$/g, '');
const lowered = normalized.toLowerCase();
if (!ALLOWED_CHARS_RE.test(lowered)) return '';
return lowered;
}
export function validateChannelDisplayName(value) {
@@ -73,7 +58,7 @@ export function channelNameErrorText(code) {
case 'too_long':
return 'Название слишком длинное: максимум 32 символа.';
case 'bad_chars':
return 'Разрешены кириллица, латиница, цифры, пробел, _ и -.';
return 'Разрешены только латиница, цифры, _ и -.';
case 'reserved':
return 'Название "0" зарезервировано.';
default: