Frontend included in repository.
This commit is contained in:
11
cista/util/filename.py
Normal file
11
cista/util/filename.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from pathvalidate import sanitize_filepath
|
||||
import unicodedata
|
||||
from pathlib import PurePosixPath
|
||||
|
||||
def sanitize(filename: str) -> str:
|
||||
filename = unicodedata.normalize("NFC", filename)
|
||||
# UNIX filenames can contain backslashes but for compatibility we replace them with dashes
|
||||
filename = filename.replace("\\", "-")
|
||||
filename = sanitize_filepath(filename)
|
||||
filename = filename.strip("/")
|
||||
return PurePosixPath(filename).as_posix()
|
||||
Reference in New Issue
Block a user