Fix/slugify with german umlaut ss (#7029)
* more tests for slugify * Fix german umlauts in slugify * Update __init__.py
This commit is contained in:
1 parent
4d9e681fc1
commit
3c35d5ea58
2 files changed
+10
-2
No files matched your search
@@ -22,6 +22,9 @@ U = TypeVar('U')
|
||||
RE_SANITIZE_FILENAME = re.compile(r'(~|\.\.|/|\\)')
|
||||
RE_SANITIZE_PATH = re.compile(r'(~|\.(\.)+)')
|
||||
RE_SLUGIFY = re.compile(r'[^a-z0-9_]+')
|
||||
TBL_SLUGIFY = {
|
||||
ord('ß'): 'ss'
|
||||
}
|
||||
|
||||
|
||||
def sanitize_filename(filename: str) -> str:
|
||||
@@ -36,9 +39,13 @@ def sanitize_path(path: str) -> str:
|
||||
|
||||
def slugify(text: str) -> str:
|
||||
"""Slugify a given text."""
|
||||
text = normalize('NFKD', text).lower().replace(" ", "_")
|
||||
text = normalize('NFKD', text)
|
||||
text = text.lower()
|
||||
text = text.replace(" ", "_")
|
||||
text = text.translate(TBL_SLUGIFY)
|
||||
text = RE_SLUGIFY.sub("", text)
|
||||
|
||||
return RE_SLUGIFY.sub("", text)
|
||||
return text
|
||||
|
||||
|
||||
def repr_helper(inp: Any) -> str:
|
||||
|
||||
Reference in new issue
Block a user