Opened 9 years ago
Closed 8 years ago
#26621 closed Bug (fixed)
simplify_regex handles named capture groups incorrectly
Description (last modified by ) ¶
For example using a regex from Django Rest Framework docs:
>>> from django.contrib.admindocs.views import simplify_regex >>> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$') '/<version>)/bookings/<pk>/'
The closing parenthesis in the output is unexpected.
Escaping the /
does not seem to help.
Change History (6)
comment:1 by , 9 years ago
Component: | Uncategorized → contrib.admindocs |
---|---|
Description: | modified (diff) |
Summary: | simplify_regex having problems with named capture groups → simplify_regex handles named capture groups incorrectly |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:2 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 9 years ago
comment:5 by , 9 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
PR with comments for improvement.
Note:
See TracTickets
for help on using tickets.
@cancan101
If you change your regex to
^(?P<version>v1|v2)/bookings/(?P<pk>[0-9]+)/$
it will work as expected (both the regex andsimplify_regex
).But yes,
simplify_regex
needs to be fixed.