1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #26621 -- Added tests for admindocs.views.simplify_regex().

This commit is contained in:
Tim Graham
2016-05-30 09:44:33 -04:00
parent 995d09ead4
commit 16a842b379
2 changed files with 13 additions and 4 deletions

View File

@@ -394,9 +394,9 @@ non_named_group_matcher = re.compile(r'\(.*?\)')
def simplify_regex(pattern):
"""
Clean up urlpattern regexes into something somewhat readable by Mere Humans:
turns something like "^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$"
into "<sport_slug>/athletes/<athlete_slug>/"
Clean up urlpattern regexes into something more readable by humans. For
example, turn "^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$"
into "/<sport_slug>/athletes/<athlete_slug>/".
"""
# handle named groups first
pattern = named_group_matcher.sub(lambda m: m.group(1), pattern)