Skip to content

Commit

Permalink
Make prettier urls if query is empty dict (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
xen authored and asvetlov committed Sep 7, 2016
1 parent 5617801 commit ebce967
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_info(self):

@staticmethod
def _append_query(url, query):
if query is not None:
if query:
return url + "?" + urlencode(query)
else:
return url
Expand Down
9 changes: 9 additions & 0 deletions tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,15 @@ def test_params_update_path_and_url(make_request):
assert req.url == 'http://python.org/?test=foo&test=baz'


def test_params_empty_path_and_url(make_request):
req_empty = make_request('get', 'http://python.org', params={})
assert req_empty.path == '/'
assert req_empty.url == 'http://python.org/'
req_none = make_request('get', 'http://python.org')
assert req_none.path == '/'
assert req_none.url == 'http://python.org/'


def test_gen_netloc_all(make_request):
req = make_request('get',
'https://aiohttp:pwpwpw@' +
Expand Down

0 comments on commit ebce967

Please sign in to comment.