diff --git a/tdclient/test/util_test.py b/tdclient/test/util_test.py index 48ec0c1..0a7314e 100644 --- a/tdclient/test/util_test.py +++ b/tdclient/test/util_test.py @@ -1,6 +1,6 @@ import pytest -from tdclient.util import normalize_connector_config +from tdclient.util import create_url, normalize_connector_config def test_normalize_connector_config(): @@ -64,3 +64,7 @@ def test_normalize_conector_has_sibling_keys(): with pytest.raises(ValueError): normalize_connector_config(config) + + +def test_create_url_with_slash(): + assert create_url("/query/{query_name}", query_name="foo/bar") == "/query/foo%2Fbar" diff --git a/tdclient/util.py b/tdclient/util.py index 2940cae..b5e81a2 100644 --- a/tdclient/util.py +++ b/tdclient/util.py @@ -17,7 +17,7 @@ def create_url(tmpl, **values): tmpl (str): url template values (dict): values for url """ - quoted_values = {k: urlquote(str(v)) for k, v in values.items()} + quoted_values = {k: urlquote(str(v), safe="") for k, v in values.items()} return tmpl.format(**quoted_values)