strip trailing and leading extra dashes
those are introduced if non-word characters are found, and are ugly
@@ -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):
