lib.Uri.query_dict: Add property
Uri exposes the query as a raw string only, so a consumer that wants the query's key/value pairs has to parse the string itself with urllib.parse. Add a cached property query_dict that returns None when the Uri has no query and a dictionary of the query's key/value pairs when it does. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
53c45e11de
commit
64f5246d78
1 changed files with 15 additions and 0 deletions
|
|
@ -109,4 +109,11 @@ assert u.new_replace_path('etc').to_string == \
|
|||
assert 'pkg-filter=url=~jw.dev' in u.full
|
||||
assert Uri('ssh://host/path').query == ''
|
||||
|
||||
# query_dict is None without a query and a key/value dict with one
|
||||
assert Uri('ssh://host/path').query_dict is None
|
||||
u = Uri('kvfile://host/?pkg-filter=url=~jw.dev')
|
||||
assert u.query_dict == {'pkg-filter': 'url=~jw.dev'}
|
||||
u = Uri('https://example.com/?a=1&b=two')
|
||||
assert u.query_dict == {'a': '1', 'b': 'two'}
|
||||
|
||||
print('All Uri tests passed')
|
||||
|
|
|
|||
Loading…
Reference in a new issue