File size: 188 Bytes
b4c7867
 
 
 
 
 
 
1
2
3
4
5
6
7
import re

def safe_name(s: str) -> str:
    s = (s or "").strip()
    s = re.sub(r"[^a-zA-Z0-9_\- ]+", "", s)
    s = re.sub(r"\s+", " ", s).strip()
    return s[:60] if s else "Untitled"