mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 21:14:19 +01:00
strip trailing and leading extra dashes
those are introduced if non-word characters are found, and are ugly
This commit is contained in:
parent
914dba4152
commit
5ef68783a8
1 changed files with 2 additions and 1 deletions
|
|
@ -236,12 +236,13 @@ def slug(text):
|
|||
2. shift everything to lowercase
|
||||
3. strip whitespace
|
||||
4. replace other non-word characters with dashes
|
||||
5. strip extra dashes
|
||||
|
||||
This somewhat duplicates the :func:`Google.slugify` function but
|
||||
slugify is not as generic as this one, which can be reused
|
||||
elsewhere.
|
||||
"""
|
||||
return re.sub(r'\W+', '-', unidecode(text).lower().strip())
|
||||
return re.sub(r'\W+', '-', unidecode(text).lower().strip()).strip('-')
|
||||
|
||||
|
||||
class Backend(object):
|
||||
|
|
|
|||
Loading…
Reference in a new issue