utils: Fix corner case in format_proxy scheme handling
This commit is contained in:
parent
8434896f2d
commit
8cf9da3d55
@ -25,7 +25,7 @@ def format_proxy(proxy_config):
|
||||
if port < 0:
|
||||
port = 80
|
||||
|
||||
return template.format(scheme=proxy_config.get('scheme', 'http'),
|
||||
return template.format(scheme=proxy_config.get('scheme') or 'http',
|
||||
username=proxy_config.get('username'),
|
||||
password=proxy_config.get('password'),
|
||||
hostname=proxy_config['hostname'], port=port)
|
||||
|
||||
@ -10,6 +10,7 @@ from mopidy.utils import http
|
||||
@pytest.mark.parametrize("config,expected", [
|
||||
({}, None),
|
||||
({'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),
|
||||
({'scheme': None, 'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),
|
||||
({'scheme': 'https', 'hostname': 'proxy.lan'}, 'https://proxy.lan:80'),
|
||||
({'username': 'user', 'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),
|
||||
({'password': 'pass', 'hostname': 'proxy.lan'}, 'http://proxy.lan:80'),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user