forked from forks/microblog.pub
Add slugify helper
This commit is contained in:
parent
3d049da2e5
commit
c985dd84c3
1 changed files with 8 additions and 0 deletions
8
app/utils/text.py
Normal file
8
app/utils/text.py
Normal file
|
@ -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("-_")
|
Loading…
Reference in a new issue