import re def slugify(text: str, maxlen: int = 30) -> str: return re.sub(r'[^a-z0-9]+', '-', (text or "").lower()).strip('-')[:maxlen]