Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check for bool in parse_query #2759

Merged
merged 2 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion panel/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from panel.io.notebook import render_mimebundle
from panel.pane import PaneBase
from panel.util import get_method_owner, abbreviated_repr
from panel.util import get_method_owner, abbreviated_repr, parse_query


def test_get_method_owner_class():
Expand Down Expand Up @@ -37,3 +37,15 @@ def test_abbreviated_repr_list():
def test_abbreviated_repr_ordereddict():
assert (abbreviated_repr(OrderedDict([('key', 'some really, really long string')]))
== "OrderedDict([('key', ...])")


def test_parse_query():
query = '?bool=true&int=2&float=3.0&json=["a"%2C+"b"]'
expected_results = {
"bool": True,
"int": 2,
"float": 3.0,
"json": ["a", "b"],
}
results = parse_query(query)
assert expected_results == results
2 changes: 2 additions & 0 deletions panel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def parse_query(query):
query[k] = float(v)
elif v.startswith('[') or v.startswith('{'):
query[k] = json.loads(v)
elif v.lower() in ("true", "false"):
query[k] = v.lower() == "true"
return query


Expand Down