Merge "Support <scheme>://<netloc>/<prefix> endpoints"

This commit is contained in:
Jenkins 2016-04-22 19:19:16 +00:00 committed by Gerrit Code Review
commit 4a4443dcab
2 changed files with 5 additions and 1 deletions

View File

@ -35,7 +35,8 @@ def parse_url(filt, url):
path = result.path
vstr = VERSION_PATTERN.search(path)
if not vstr:
return result.scheme + "://" + result.netloc + "/" + filt.get_path()
return (result.scheme + "://" + result.netloc + path.rstrip('/') +
'/' + filt.get_path())
start, end = vstr.span()
prefix = path[:start]
version = '/' + filt.get_path(path[start + 1:end])

View File

@ -27,6 +27,9 @@ class TestSession(testtools.TestCase):
self.assertEqual(
"http://127.0.0.1:9292/v1",
session.parse_url(filt, "http://127.0.0.1:9292"))
self.assertEqual(
"http://127.0.0.1:9292/foo/v1",
session.parse_url(filt, "http://127.0.0.1:9292/foo"))
self.assertEqual(
"http://127.0.0.1:9292/v2",
session.parse_url(filt, "http://127.0.0.1:9292/v2.0"))