Use urlunparse to reconstruct base_url
Using string replace to replace the new path back onto the old path fails when there is no path setup in the catalog initially. Instead of this lets use the inverse to the urlparse previously performed. Change-Id: I931f0c558aafc8dfaa5519744c6e4e7fcffc3205 Closes-Bug: #1552475
This commit is contained in:
parent
22dd1c9d94
commit
823a00433f
|
@ -325,13 +325,24 @@ class KeystoneV2AuthProvider(KeystoneAuthProvider):
|
|||
|
||||
parts = urlparse.urlparse(_base_url)
|
||||
if filters.get('api_version', None) is not None:
|
||||
version_path = '/%s' % filters['api_version']
|
||||
path = re.sub(r'(^|/)+v\d+(?:\.\d+)?',
|
||||
'/' + filters['api_version'],
|
||||
version_path,
|
||||
parts.path,
|
||||
count=1)
|
||||
_base_url = _base_url.replace(parts.path, path)
|
||||
_base_url = urlparse.urlunparse((parts.scheme,
|
||||
parts.netloc,
|
||||
path or version_path,
|
||||
parts.params,
|
||||
parts.query,
|
||||
parts.fragment))
|
||||
if filters.get('skip_path', None) is not None and parts.path != '':
|
||||
_base_url = _base_url.replace(parts.path, "/")
|
||||
_base_url = urlparse.urlunparse((parts.scheme,
|
||||
parts.netloc,
|
||||
'/',
|
||||
parts.params,
|
||||
parts.query,
|
||||
parts.fragment))
|
||||
|
||||
return _base_url
|
||||
|
||||
|
@ -447,13 +458,24 @@ class KeystoneV3AuthProvider(KeystoneAuthProvider):
|
|||
|
||||
parts = urlparse.urlparse(_base_url)
|
||||
if filters.get('api_version', None) is not None:
|
||||
version_path = '/%s' % filters['api_version']
|
||||
path = re.sub(r'(^|/)+v\d+(?:\.\d+)?',
|
||||
'/' + filters['api_version'],
|
||||
version_path,
|
||||
parts.path,
|
||||
count=1)
|
||||
_base_url = _base_url.replace(parts.path, path)
|
||||
_base_url = urlparse.urlunparse((parts.scheme,
|
||||
parts.netloc,
|
||||
path or version_path,
|
||||
parts.params,
|
||||
parts.query,
|
||||
parts.fragment))
|
||||
if filters.get('skip_path', None) is not None:
|
||||
_base_url = _base_url.replace(parts.path, "/")
|
||||
_base_url = urlparse.urlunparse((parts.scheme,
|
||||
parts.netloc,
|
||||
'/',
|
||||
parts.params,
|
||||
parts.query,
|
||||
parts.fragment))
|
||||
|
||||
return _base_url
|
||||
|
||||
|
|
Loading…
Reference in New Issue