Skip to content

Commit ee616d0

Browse files
committed
Fix route parameters
1 parent 37760bb commit ee616d0

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

docs/examples/python/route-parameters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def all_messages():
6363

6464
@component
6565
def messages_with():
66-
names = set(use_params()["names"].split("-")) # and here we use the path param
66+
names = tuple(use_params()["names"].split("-")) # and here we use the path param
6767
messages = [msg for msg in message_data if tuple(msg["with"]) == names]
6868
return html.div(
6969
html.h1(f"Messages with {', '.join(names)} 💬"),

src/reactpy_router/resolvers.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def parse_path(self, path: str) -> re.Pattern[str]:
4343
try:
4444
conversion_info = self.registered_converters[param_type]
4545
except KeyError as e:
46-
raise ValueError(
47-
f"Unknown conversion type {param_type!r} in {path!r}"
48-
) from e
46+
raise ValueError(f"Unknown conversion type {param_type!r} in {path!r}") from e
4947

5048
# Add the string before the match to the pattern
5149
pattern += re.escape(path[last_match_end : match.start()])
@@ -69,9 +67,9 @@ def resolve(self, path: str) -> tuple[Any, dict[str, Any]] | None:
6967
if match:
7068
# Convert the matched groups to the correct types
7169
params = {
72-
parameter_name.strip("_numeric_"): self.converter_mapping[
73-
parameter_name
74-
](value)
70+
parameter_name[len("_numeric_") :]
71+
if parameter_name.startswith("_numeric_")
72+
else parameter_name: self.converter_mapping[parameter_name](value)
7573
for parameter_name, value in match.groupdict().items()
7674
}
7775
return (self.element, params)

0 commit comments

Comments
 (0)