File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,11 @@ def paths(dir_site: str) -> Paths:
5959
6060@lru_cache (maxsize = 256 )
6161def slugify (s : str ) -> str :
62- """Return string with forbidden characters replaced with hyphens.
62+ """Return string with forbidden characters replaced with hyphens. Different input strings may result in the same output.
6363
64- Consecutive forbidden characters are replaced with a single hyphen.
65- Leading and trailing whitespace and hyphens are stripped.
66- Different input strings may result in the same output.
64+ Consecutive forbidden characters are replaced with a single hyphen. Leading and trailing whitespace is stripped.
6765 """
68- return re .sub (re_forbidden , '- ' , s .strip ()).strip ('-' )
66+ return re .sub (re_forbidden , '# ' , s .strip ()).strip ('#' ). replace ( '#' , '-' )
6967
7068
7169def latest_file_change (root : str ):
@@ -84,9 +82,9 @@ def walk_dir(path):
8482 for entry in walk_dir (root ):
8583 try :
8684 mtime = entry .stat ().st_mtime
87- except FileNotFoundError : # skip race condition
85+ except FileNotFoundError : # skip race condition
8886 continue
8987 if mtime > latest_mtime :
9088 latest_mtime = mtime
9189
92- return latest_mtime
90+ return latest_mtime
Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ def test_slugify():
1919 ('multiple spaces' , 'multiple-spaces' ),
2020 ('c♯dim' , 'c♯dim' ),
2121 ('_85QotzbzHY' , '_85QotzbzHY' ),
22+ ('-08LooL_3Gw' , '-08LooL_3Gw' ),
23+ ('c++' , 'c++' ),
24+ ('c--' , 'c--' ),
25+ ('#hash#' , 'hash' ),
2226 ('dot.dot' , 'dot.dot' ),
27+ ('@username' , '@username' ),
2328 ]:
2429 assert logya .util .slugify (value ) == expected
2530
You can’t perform that action at this time.
0 commit comments