Merge pull request #1025 from nkoshell/route-version-params

Route version params
This commit is contained in:
Raphael Deem 2017-11-20 23:43:22 -08:00 committed by GitHub
commit 7a3f9daccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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