Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Adrian Holovaty authored May 15, 2006
1  AUTHORS
@@ -106,6 +106,7 @@ answer newbie questions, and generally made Django that much better:
106 106
     Swaroop C H <http://www.swaroopch.info>
107 107
     Aaron Swartz <http://www.aaronsw.com/>
108 108
     Tom Tobin
  109
+    Tom Insam
109 110
     Joe Topjian <http://joe.terrarum.net/geek/code/python/django/>
110 111
     Malcolm Tredinnick
111 112
     Amit Upadhyay
4  django/contrib/admin/media/js/urlify.js
@@ -9,7 +9,7 @@ function URLify(s, num_chars) {
9 9
     s = s.replace(r, '');
10 10
     s = s.replace(/[^-A-Z0-9\s]/gi, '');  // remove unneeded chars
11 11
     s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
12  
-    s = s.replace(/\s+/g, '-');      // convert spaces to hyphens
  12
+    s = s.replace(/[-\s]+/g, '-');   // convert spaces to hyphens
13 13
     s = s.toLowerCase();             // convert to lowercase
14 14
     return s.substring(0, num_chars);// trim to first num_chars chars
15  
-}
  15
+}
2  django/template/defaultfilters.py
@@ -66,7 +66,7 @@ def make_list(value):
66 66
 def slugify(value):
67 67
     "Converts to lowercase, removes non-alpha chars and converts spaces to hyphens"
68 68
     value = re.sub('[^\w\s-]', '', value).strip().lower()
69  
-    return re.sub('\s+', '-', value)
  69
+    return re.sub('[-\s]+', '-', value)
70 70
 
71 71
 def stringformat(value, arg):
72 72
     """

0 notes on commit 51f6a94

Please sign in to comment.
Something went wrong with that request. Please try again.