# HG changeset patch # User Marcin Kuzminski # Date 2016-11-23 12:56:03 # Node ID 0b331b7a95d0f4ecea802c44a5247b8135136746 # Parent df91b5ff6aac457682a8a0d3deb6b14ed07d1dff slugs: make special chars not be replaced by '-'. THis produces a much better slugs. Eg /fo;o/b|ar/ => will be /foo/bar/ and not /fo-o/b-ar/ Which doesn't make sense from human readable names. diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -62,7 +62,7 @@ REMOVED_REPO_PAT = re.compile(r'rm__\d{8 # String which contains characters that are not allowed in slug names for # repositories or repository groups. It is properly escaped to use it in # regular expressions. -SLUG_BAD_CHARS = re.escape('`?=[]\;\'"<>,/~!@#$%^&*()+{}|: ') +SLUG_BAD_CHARS = re.escape('`?=[]\;\'"<>,/~!@#$%^&*()+{}|:') # Regex that matches forbidden characters in repo/group slugs. SLUG_BAD_CHAR_RE = re.compile('[{}]'.format(SLUG_BAD_CHARS)) @@ -85,7 +85,8 @@ def repo_name_slug(value): replacement_char = '-' slug = remove_formatting(value) - slug = SLUG_BAD_CHAR_RE.sub(replacement_char, slug) + slug = SLUG_BAD_CHAR_RE.sub('', slug) + slug = re.sub('[\s]+', '-', slug) slug = collapse(slug, replacement_char) return slug