0
0
mirror of https://github.com/django/django.git synced 2024-11-24 20:07:01 +01:00

Fixed #1849 -- Slugifying now collapses consecutive hyphens to a single hyphen. Thanks, Tom Insam

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2905 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-05-15 04:20:04 +00:00
parent fe257d49da
commit 51f6a9442c
3 changed files with 4 additions and 3 deletions

View File

@ -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 File

@ -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 File

@ -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):
"""