diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-05-15 04:20:04 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-05-15 04:20:04 +0000 |
| commit | 51f6a9442c21d6288ccca9b8d9ebaf2f6ecd5b9d (patch) | |
| tree | 31303755fd0b74702a34babfd542789d2d22fcd6 | |
| parent | fe257d49da9a789ec9217e05b4e321ccd360650e (diff) | |
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
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | django/contrib/admin/media/js/urlify.js | 4 | ||||
| -rw-r--r-- | django/template/defaultfilters.py | 2 |
3 files changed, 4 insertions, 3 deletions
@@ -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 diff --git a/django/contrib/admin/media/js/urlify.js b/django/contrib/admin/media/js/urlify.js index 8b8dbfa59e..90d11c435a 100644 --- a/django/contrib/admin/media/js/urlify.js +++ b/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 -}
\ No newline at end of file +} diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index fa4975e643..7820e72342 100644 --- a/django/template/defaultfilters.py +++ b/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): """ |
