mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
requested changes
This commit is contained in:
parent
973860d9fe
commit
0ad017a573
|
@ -35,7 +35,10 @@ DynamicDetailRoute = namedtuple('DynamicDetailRoute', ['url', 'name', 'initkwarg
|
||||||
DynamicListRoute = namedtuple('DynamicListRoute', ['url', 'name', 'initkwargs'])
|
DynamicListRoute = namedtuple('DynamicListRoute', ['url', 'name', 'initkwargs'])
|
||||||
|
|
||||||
|
|
||||||
def replace_curly_brackets(url_path):
|
def escape_curly_brackets(url_path):
|
||||||
|
"""
|
||||||
|
Double brackets in regex of url_path for escape string formatting
|
||||||
|
"""
|
||||||
if ('{' and '}') in url_path:
|
if ('{' and '}') in url_path:
|
||||||
url_path = url_path.replace('{', '{{').replace('}', '}}')
|
url_path = url_path.replace('{', '{{').replace('}', '}}')
|
||||||
return url_path
|
return url_path
|
||||||
|
@ -184,7 +187,7 @@ class SimpleRouter(BaseRouter):
|
||||||
initkwargs = route.initkwargs.copy()
|
initkwargs = route.initkwargs.copy()
|
||||||
initkwargs.update(method_kwargs)
|
initkwargs.update(method_kwargs)
|
||||||
url_path = initkwargs.pop("url_path", None) or methodname
|
url_path = initkwargs.pop("url_path", None) or methodname
|
||||||
url_path = replace_curly_brackets(url_path)
|
url_path = escape_curly_brackets(url_path)
|
||||||
url_name = initkwargs.pop("url_name", None) or url_path
|
url_name = initkwargs.pop("url_name", None) or url_path
|
||||||
ret.append(Route(
|
ret.append(Route(
|
||||||
url=replace_methodname(route.url, url_path),
|
url=replace_methodname(route.url, url_path),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user