{{{
simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
'/<version>)/bookings/<pk>/'
}}}
Escaping the `/` does not seem to help.
--
Ticket URL: <https://code.djangoproject.com/ticket/26621>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* version: 1.9 => master
* needs_tests: => 0
* needs_docs: => 0
Old description:
> For example using the regex from [here](http://www.django-rest-
> framework.org/api-guide/versioning/):
>
> {{{
> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
>
> '/<version>)/bookings/<pk>/'
> }}}
>
> Escaping the `/` does not seem to help.
New description:
For example using the regex from [http://www.django-rest-framework.org
/api-guide/versioning/ here]:
{{{
simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
'/<version>/bookings/<pk>/'
}}}
Escaping the `/` does not seem to help.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:1>
Old description:
> For example using the regex from [http://www.django-rest-framework.org
> /api-guide/versioning/ here]:
>
> {{{
> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
>
> '/<version>/bookings/<pk>/'
> }}}
>
> Escaping the `/` does not seem to help.
New description:
For example using the regex from [http://www.django-rest-framework.org
/api-guide/versioning/ here]:
{{{
simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
'/<version>/bookings/<pk>/'
}}}
Escaping the `/` does not seem to help.
EDIT: Somehow I pasted the wrong output. I come out as
`'/<version>)/bookings/<pk>/'` which is clearly broken.
--
Comment (by cancan101):
Somehow I pasted the wrong output. I come out as
`'/<version>)/bookings/<pk>/'`
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:2>
* needs_better_patch: => 0
* component: Uncategorized => contrib.admindocs
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Old description:
> For example using the regex from [here](http://www.django-rest-
> framework.org/api-guide/versioning/):
>
> {{{
> simplify_regex(r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$')
>
> '/<version>)/bookings/<pk>/'
> }}}
>
> Escaping the `/` does not seem to help.
New description:
For example using a regex from [http://www.django-rest-framework.org/api-
guide/versioning/ 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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:1>
* status: new => assigned
* owner: nobody => ketanbhatt
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:2>
Comment (by ketanbhatt):
@cancan101
If you change your regex to
`^(?P<version>v1|v2)/bookings/(?P<pk>[0-9]+)/$` it will work as expected
(both the regex and `simplify_regex`).
But yes, `simplify_regex` needs to be fixed.
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:3>
Comment (by Tim Graham <timograham@…>):
In [changeset:"16a842b3795ca78a5918538ab6b9f1afbd718f72" 16a842b3]:
{{{
#!CommitTicketReference repository=""
revision="16a842b3795ca78a5918538ab6b9f1afbd718f72"
Refs #26621 -- Added tests for admindocs.views.simplify_regex().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:4>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/6660 PR] with comments for
improvement.
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:5>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:6>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f0ef0c49e9284f262fbc63e8a497699ca4a248fe" f0ef0c4]:
{{{
#!CommitTicketReference repository=""
revision="f0ef0c49e9284f262fbc63e8a497699ca4a248fe"
Fixed #26621 -- Corrected simplify_regex()'s handling of named capture
groups.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26621#comment:6>