UI - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: латинский URL workspace

This commit is contained in:
DCCONSTRUCTIONS
2026-05-12 23:12:07 +03:00
parent 268ab2c9b9
commit a86ed9f5f3
3 changed files with 64 additions and 10 deletions
@@ -0,0 +1,48 @@
const CYRILLIC_TO_LATIN: Record<string, string> = {
а: "a",
б: "b",
в: "v",
г: "g",
д: "d",
е: "e",
ё: "e",
ж: "zh",
з: "z",
и: "i",
й: "y",
к: "k",
л: "l",
м: "m",
н: "n",
о: "o",
п: "p",
р: "r",
с: "s",
т: "t",
у: "u",
ф: "f",
х: "kh",
ц: "ts",
ч: "ch",
ш: "sh",
щ: "shch",
ъ: "",
ы: "y",
ь: "",
э: "e",
ю: "yu",
я: "ya",
};
export const createWorkspaceSlug = (value: string) =>
value
.trim()
.toLocaleLowerCase()
.split("")
.map((character) => CYRILLIC_TO_LATIN[character] ?? character)
.join("")
.normalize("NFKD")
.replace(/[\u0300-\u036f]/g, "")
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "")
.replace(/-{2,}/g, "-");