summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docker/utils/utils.py4
-rw-r--r--tests/unit/utils_test.py5
2 files changed, 7 insertions, 2 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index b565732..e1c7ad0 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -453,8 +453,8 @@ def parse_host(addr, is_win32=False, tls=False):
"Bind address needs a port: {0}".format(addr))
if proto == "http+unix" or proto == 'npipe':
- return "{0}://{1}".format(proto, host)
- return "{0}://{1}:{2}{3}".format(proto, host, port, path)
+ return "{0}://{1}".format(proto, host).rstrip('/')
+ return "{0}://{1}:{2}{3}".format(proto, host, port, path).rstrip('/')
def parse_devices(devices):
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index 2a2759d..059c82d 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -522,6 +522,11 @@ class ParseHostTest(base.BaseTestCase):
expected_result = 'https://myhost.docker.net:3348'
assert parse_host(host_value, tls=True) == expected_result
+ def test_parse_host_trailing_slash(self):
+ host_value = 'tcp://myhost.docker.net:2376/'
+ expected_result = 'http://myhost.docker.net:2376'
+ assert parse_host(host_value) == expected_result
+
class ParseRepositoryTagTest(base.BaseTestCase):
sha = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'