Fix prefix handling for relative urls

Basically we just remove the trailing prefix / and leading path /
and then join with /.
This commit is contained in:
Chris Dent 2017-02-24 12:43:26 -05:00
parent cc79b5fd98
commit 22bef30f81
1 changed files with 3 additions and 1 deletions

View File

@ -63,7 +63,9 @@ def create_url(base_url, host, port=None, prefix='', ssl=False):
# this covers most common cases and will be okay until someone
# reports a bug.
if prefix and not path.startswith(prefix):
path = '%s%s' % (prefix, path)
prefix = prefix.rstrip('/')
path = path.lstrip('/')
path = '%s/%s' % (prefix, path)
return urlparse.urlunsplit((scheme, netloc, path, query_string, ''))