diff --git a/sanic/router.py b/sanic/router.py index b601622c..2ba3140c 100644 --- a/sanic/router.py +++ b/sanic/router.py @@ -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)) + uri = "/".join(["/v{}".format(version.strip('/')), uri.lstrip('/')]) # add regular version self._add(uri, methods, handler, host, name)