Add clean paths util #17

Merged
perl_d merged 5 commits from refactor/tidy into main 2026-08-07 11:07:08 +02:00
Showing only changes of commit 1cd7aa5acf - Show all commits
+9
View File
@@ -0,0 +1,9 @@
import re
def clean_filename(filename: str) -> str:
cleaned = re.sub(r"[^A-Za-z0-9._-]", "_", filename.strip())
cleaned = cleaned.strip("._-")
if not cleaned:
raise ValueError("Filename is empty after sanitization.")
return cleaned