Skip to content

Commit 7a242e1

Browse files
committed
Add slug conversion type
1 parent 9e72ca0 commit 7a242e1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/reactpy_router/routers.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,32 @@ class ConversionInfo(TypedDict):
7070

7171

7272
CONVERSION_TYPES: dict[str, ConversionInfo] = {
73-
"str": {
74-
"regex": r"[^/]+",
75-
"func": str,
76-
},
7773
"int": {
7874
"regex": r"\d+",
7975
"func": int,
8076
},
81-
"float": {
82-
"regex": r"\d+(\.\d+)?",
83-
"func": float,
77+
"str": {
78+
"regex": r"[^/]+",
79+
"func": str,
8480
},
8581
"uuid": {
8682
"regex": r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
8783
"func": uuid.UUID,
8884
},
85+
"slug": {
86+
"regex": r"[-a-zA-Z0-9_]+",
87+
"func": str,
88+
},
8989
"path": {
9090
"regex": r".+",
9191
"func": str,
9292
},
93+
"float": {
94+
"regex": r"\d+(\.\d+)?",
95+
"func": float,
96+
},
9397
}
94-
"""The supported conversion types"""
98+
"""The conversion types supported by the default Resolver. You can add more types if needed."""
9599

96100

97101
browser_router = create_router(SimpleResolver)

0 commit comments

Comments
 (0)