Added regex escaping for Router.add() version parameter

This commit is contained in:
Nikita Koshelev 2017-11-18 01:22:42 +03:00
parent 820d8c7bf5
commit 8e7475ccf6

View File

@ -119,10 +119,8 @@ class Router:
:return: Nothing :return: Nothing
""" """
if version is not None: if version is not None:
if uri.startswith('/'): version = re.escape(str(version))
uri = "/".join(["/v{}".format(str(version)), uri[1:]]) uri = "/".join(["/v{}".format(version.strip('/')), uri.lstrip('/')])
else:
uri = "/".join(["/v{}".format(str(version)), uri])
# add regular version # add regular version
self._add(uri, methods, handler, host, name) self._add(uri, methods, handler, host, name)