diff --git a/AUTHORS b/AUTHORS index 4e44004768..5864c7107f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -106,6 +106,7 @@ answer newbie questions, and generally made Django that much better: Swaroop C H Aaron Swartz Tom Tobin + Tom Insam Joe Topjian 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): """