Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #1849 -- Slugifying now collapses consecutive hyphens to a sing…

…le hyphen. Thanks, Tom Insam

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2905 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 51f6a9442c21d6288ccca9b8d9ebaf2f6ecd5b9d 1 parent fe257d4
@adrianholovaty adrianholovaty authored
View
1  AUTHORS
@@ -106,6 +106,7 @@ answer newbie questions, and generally made Django that much better:
Swaroop C H <http://www.swaroopch.info>
Aaron Swartz <http://www.aaronsw.com/>
Tom Tobin
+ Tom Insam
Joe Topjian <http://joe.terrarum.net/geek/code/python/django/>
Malcolm Tredinnick
Amit Upadhyay
View
4 django/contrib/admin/media/js/urlify.js
@@ -9,7 +9,7 @@ function URLify(s, num_chars) {
s = s.replace(r, '');
s = s.replace(/[^-A-Z0-9\s]/gi, ''); // remove unneeded chars
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
- s = s.replace(/\s+/g, '-'); // convert spaces to hyphens
+ s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
s = s.toLowerCase(); // convert to lowercase
return s.substring(0, num_chars);// trim to first num_chars chars
-}
+}
View
2  django/template/defaultfilters.py
@@ -66,7 +66,7 @@ def make_list(value):
def slugify(value):
"Converts to lowercase, removes non-alpha chars and converts spaces to hyphens"
value = re.sub('[^\w\s-]', '', value).strip().lower()
- return re.sub('\s+', '-', value)
+ return re.sub('[-\s]+', '-', value)
def stringformat(value, arg):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.