diff options
| author | Daniel Nephin <dnephin@gmail.com> | 2016-08-10 14:52:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-10 14:52:07 -0400 |
| commit | 7de30c3a9b75b12f26745c662f5d5bd3e1839021 (patch) | |
| tree | 2e9171420391a57df42d44efc2f82c9e949d1058 | |
| parent | 876e7b49daeef7cd403cf1932c8f870521a60eab (diff) | |
| parent | 08b284ab399e9bf19296c020e158968ba3fb800b (diff) | |
| download | docker-py-7de30c3a9b75b12f26745c662f5d5bd3e1839021.tar.gz | |
Merge pull request #1142 from TomasTomecek/dont-url-encode-repository-name
docker client consistency: don't quote ':/'
| -rw-r--r-- | docker/client.py | 4 | ||||
| -rw-r--r-- | tests/unit/api_test.py | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/docker/client.py b/docker/client.py index c3e5874..771412e 100644 --- a/docker/client.py +++ b/docker/client.py @@ -14,6 +14,7 @@ import json import struct +from functools import partial import requests import requests.exceptions @@ -156,7 +157,8 @@ class Client( 'instead'.format(arg, type(arg)) ) - args = map(six.moves.urllib.parse.quote_plus, args) + quote_f = partial(six.moves.urllib.parse.quote_plus, safe="/:") + args = map(quote_f, args) if kwargs.get('versioned_api', True): return '{0}/v{1}{2}'.format( diff --git a/tests/unit/api_test.py b/tests/unit/api_test.py index 696c073..712f57e 100644 --- a/tests/unit/api_test.py +++ b/tests/unit/api_test.py @@ -159,9 +159,15 @@ class DockerApiTest(DockerClientTest): '{0}{1}'.format(url_prefix, 'hello/somename/world/someothername') ) - url = self.client._url('/hello/{0}/world', '/some?name') + url = self.client._url('/hello/{0}/world', 'some?name') self.assertEqual( - url, '{0}{1}'.format(url_prefix, 'hello/%2Fsome%3Fname/world') + url, '{0}{1}'.format(url_prefix, 'hello/some%3Fname/world') + ) + + url = self.client._url("/images/{0}/push", "localhost:5000/image") + self.assertEqual( + url, + '{0}{1}'.format(url_prefix, 'images/localhost:5000/image/push') ) def test_url_invalid_resource(self): |
