Merge pull request #20229 from zhsj/fix-dashboard-prefix

pybind/mgr/dashboard: fix duplicated slash in html href

Reviewed-by: John Spray <john.spray@redhat.com>
This commit is contained in:
John Spray 2018-02-05 13:07:33 +01:00 committed by GitHub
commit 66c7832c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,10 +71,11 @@ def to_sorted_array(data):
return sorted(data.iteritems())
def prepare_url_prefix(url_prefix):
"""
return '' if no prefix, or '/prefix' without slash in the end.
"""
url_prefix = urlparse.urljoin('/', url_prefix)
if url_prefix[-1] != '/':
url_prefix = url_prefix + '/'
return url_prefix
return url_prefix.rstrip('/')
class StandbyModule(MgrStandbyModule):
def serve(self):
@ -1012,7 +1013,7 @@ class Module(MgrModule):
# Publish the URI that others may use to access the service we're
# about to start serving
self.set_uri("http://{0}:{1}{2}".format(
self.set_uri("http://{0}:{1}{2}/".format(
socket.getfqdn() if server_addr == "::" else server_addr,
server_port,
url_prefix