Skip to content

Commit c371c00

Browse files
committed
Fix error on URL to host conversion
It added a '?' to the end of the path, even if there were no query parameters.
1 parent b6eb11f commit c371c00

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tests/test_connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ async def test_serve_non_tcp_listener(nursery):
160160
with pytest.raises(RuntimeError):
161161
server.port
162162
assert server.listeners[0].startswith('MemoryListener(')
163-
# TODO add support for arbitrary client streams and test here
164163

165164

166165
async def test_serve_multiple_listeners(nursery):
@@ -187,6 +186,10 @@ async def test_client_open(echo_server):
187186

188187

189188
async def test_client_open_url(echo_server):
189+
url = 'ws://{}:{}{}/path'.format(HOST, echo_server.port, RESOURCE)
190+
async with open_websocket_url(url) as conn:
191+
assert conn.path == RESOURCE + '/path'
192+
190193
url = 'ws://{}:{}{}?foo=bar'.format(HOST, echo_server.port, RESOURCE)
191194
async with open_websocket_url(url) as conn:
192195
assert conn.path == RESOURCE + '?foo=bar'

trio_websocket/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ def _url_to_host(url, ssl_context):
152152
ssl_context = url.scheme == 'wss'
153153
elif url.scheme == 'ws':
154154
raise ValueError('SSL context must be None for ws: URL scheme')
155-
resource = '{}?{}'.format(url.path, url.query_string)
156-
return url.host, url.port, resource, ssl_context
155+
return url.host, url.port, url.path_qs, ssl_context
157156

158157

159158
async def wrap_client_stream(nursery, stream, host, resource):

0 commit comments

Comments
 (0)