Mercurial > kallithea
diff rhodecode/lib/helpers.py @ 3405:a9adca4ba3c9 beta
fixed urlify changesets regex + tests
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 26 Feb 2013 00:11:59 +0100 |
parents | 5ff79fad209c |
children | b8f929bff7e3 |
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py Mon Feb 25 23:17:33 2013 +0100 +++ b/rhodecode/lib/helpers.py Tue Feb 26 00:11:59 2013 +0100 @@ -1004,21 +1004,16 @@ :param repository: repo name to build the URL with """ from pylons import url # doh, we need to re-import url to mock it later - URL_PAT = re.compile(r'(?:^|\s)([0-9a-fA-F]{12,40})(?:$|\s)') + URL_PAT = re.compile(r'(^|\s)([0-9a-fA-F]{12,40})($|\s)') def url_func(match_obj): - rev = match_obj.groups()[0] - pref = '' - suf = '' - if match_obj.group().startswith(' '): - pref = ' ' - if match_obj.group().endswith(' '): - suf = ' ' + rev = match_obj.groups()[1] + pref = match_obj.groups()[0] + suf = match_obj.groups()[2] + tmpl = ( '%(pref)s<a class="%(cls)s" href="%(url)s">' - '%(rev)s' - '</a>' - '%(suf)s' + '%(rev)s</a>%(suf)s' ) return tmpl % { 'pref': pref,