Skip to content

Commit 9d18fc9

Browse files
committed
safer query string parsing
1 parent b1192c5 commit 9d18fc9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/reactpy_router/hooks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ def use_search_params(
5757
for the current location.
5858
5959
See `urllib.parse.parse_qs` for info on this hook's parameters."""
60+
location = use_location()
61+
query_string = location.search[1:] if len(location.search) > 1 else ""
6062

6163
# TODO: In order to match `react-router`, this will need to return a tuple of the search params \
6264
# and a function to update them. This is currently not possible without reactpy core having a \
6365
# communication layer.
6466
return parse_qs(
65-
use_location().search[1:],
67+
query_string,
6668
keep_blank_values=keep_blank_values,
6769
strict_parsing=strict_parsing,
6870
errors=errors,

0 commit comments

Comments
 (0)