mirror of
https://github.com/django/django.git
synced 2025-03-05 15:02:31 +00:00
Fixed #27781 -- Made simplify_regex() remove outstanding '?' characters.
Regression in f0ef0c49e9284f262fbc63e8a497699ca4a248fe.
This commit is contained in:
parent
6478e07a62
commit
c37ec5a659
@ -430,7 +430,7 @@ def simplify_regex(pattern):
|
|||||||
pattern = replace_named_groups(pattern)
|
pattern = replace_named_groups(pattern)
|
||||||
pattern = replace_unnamed_groups(pattern)
|
pattern = replace_unnamed_groups(pattern)
|
||||||
# clean up any outstanding regex-y characters.
|
# clean up any outstanding regex-y characters.
|
||||||
pattern = pattern.replace('^', '').replace('$', '')
|
pattern = pattern.replace('^', '').replace('$', '').replace('?', '')
|
||||||
if not pattern.startswith('/'):
|
if not pattern.startswith('/'):
|
||||||
pattern = '/' + pattern
|
pattern = '/' + pattern
|
||||||
return pattern
|
return pattern
|
||||||
|
@ -336,6 +336,7 @@ class AdminDocViewFunctionsTests(SimpleTestCase):
|
|||||||
(r'^(?P<a>(x|y))/b/(?P<c>\w+)$', '/<a>/b/<c>'),
|
(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'),
|
||||||
(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'),
|
||||||
|
(r'^a/?$', '/a/'),
|
||||||
)
|
)
|
||||||
for pattern, output in tests:
|
for pattern, output in tests:
|
||||||
self.assertEqual(simplify_regex(pattern), output)
|
self.assertEqual(simplify_regex(pattern), output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user