Add slugify helper

outbox-fts
Thomas Sileo 2022-10-30 17:51:57 +01:00
rodzic 3d049da2e5
commit c985dd84c3
1 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,8 @@
import re
import unicodedata
def slugify(text: str) -> str:
value = unicodedata.normalize("NFKC", text)
value = re.sub(r"[^\w\s-]", "", value.lower())
return re.sub(r"[-\s]+", "-", value).strip("-_")