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

Fixed #28135 -- Made simplify_regex() handle non-capturing groups.

This commit is contained in:
Ayush Joshi
2022-01-14 10:03:55 +05:30
committed by Mariusz Felisiak
parent fdfa97fb16
commit 0a17666045
3 changed files with 27 additions and 2 deletions

View File

@@ -397,6 +397,13 @@ class AdminDocViewFunctionsTests(SimpleTestCase):
(r'^(?P<a>(x|y))/b/(?P<c>\w+)', '/<a>/b/<c>'),
(r'^(?P<a>(x|y))/b/(?P<c>\w+)ab', '/<a>/b/<c>ab'),
(r'^(?P<a>(x|y)(\(|\)))/b/(?P<c>\w+)ab', '/<a>/b/<c>ab'),
# Non-capturing groups.
(r'^a(?:\w+)b', '/ab'),
(r'^a(?:(x|y))', '/a'),
(r'^(?:\w+(?:\w+))a', '/a'),
(r'^a(?:\w+)/b(?:\w+)', '/a/b'),
(r'(?P<a>\w+)/b/(?:\w+)c(?:\w+)', '/<a>/b/c'),
(r'(?P<a>\w+)/b/(\w+)/(?:\w+)c(?:\w+)', '/<a>/b/<var>/c'),
# Single and repeated metacharacters.
(r'^a', '/a'),
(r'^^a', '/a'),