Skip to content

Commit e05b596

Browse files
committed
Ensure url prefixes have non-zero length
1 parent a9d6b09 commit e05b596

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/dicomweb_client/web.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,25 @@ def __init__(
251251
session = requests.session()
252252
self._session = session
253253
self.base_url = url
254+
if qido_url_prefix == '':
255+
raise ValueError(
256+
'Argument "qido_url_prefix" must not be a zero length string.'
257+
)
254258
self.qido_url_prefix = qido_url_prefix
259+
if wado_url_prefix == '':
260+
raise ValueError(
261+
'Argument "wado_url_prefix" must not be a zero length string.'
262+
)
255263
self.wado_url_prefix = wado_url_prefix
264+
if stow_url_prefix == '':
265+
raise ValueError(
266+
'Argument "stow_url_prefix" must not be a zero length string.'
267+
)
256268
self.stow_url_prefix = stow_url_prefix
269+
if delete_url_prefix == '':
270+
raise ValueError(
271+
'Argument "delete_url_prefix" must not be a zero length string.'
272+
)
257273
self.delete_url_prefix = delete_url_prefix
258274

259275
# This regular expression extracts the scheme and host name from the URL

tests/test_web.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ def test_url_prefixes(httpserver):
6565
assert client.stow_url_prefix == stow_url_prefix
6666

6767

68+
def test_url_prefixes_zero_length(httpserver):
69+
for name in ('wado', 'qido', 'stow'):
70+
kwargs = {f'{name}_url_prefix': ''}
71+
with pytest.raises(ValueError):
72+
DICOMwebClient(httpserver.url, **kwargs)
73+
74+
6875
def test_proxies(httpserver):
6976
protocol = 'http'
7077
address = 'foo.com'

0 commit comments

Comments
 (0)