From 0ad017a5735a532280c8c56ad8c66f950f0b22f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=8F=99=ED=99=98?= Date: Mon, 29 May 2017 20:55:06 +0900 Subject: [PATCH] requested changes --- rest_framework/routers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 81f8ebf78..87e58b015 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -35,7 +35,10 @@ DynamicDetailRoute = namedtuple('DynamicDetailRoute', ['url', 'name', 'initkwarg 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: url_path = url_path.replace('{', '{{').replace('}', '}}') return url_path @@ -184,7 +187,7 @@ class SimpleRouter(BaseRouter): initkwargs = route.initkwargs.copy() initkwargs.update(method_kwargs) 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 ret.append(Route( url=replace_methodname(route.url, url_path),