-
Notifications
You must be signed in to change notification settings - Fork 49
fix: handle hyphen in route #109
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
Conversation
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
crates/tuono/src/route.rs
Outdated
@@ -30,7 +30,7 @@ impl AxumInfo { | |||
let module_import = module | |||
.as_str() | |||
.to_string() | |||
.replace('/', "_") | |||
.replace(['/', '-'], "_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid this. I think this means that: route/subroute
and route-subroute
would get mapped with the same value. I'd follow the same pattern as the .
: _hyphen_
crates/tuono/src/route.rs
Outdated
@@ -186,6 +186,19 @@ mod tests { | |||
assert_eq!(dyn_info.module_import, "dyn_posts"); | |||
} | |||
|
|||
#[test] | |||
fn should_handle_hyphen() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the test. Right now we have already a test that checks for the correct route parsing. in src/app.rs
. The test name is should_collect_routes
. Could you please just add the map there? I agree that the test should better apply for the route.rs
file but I'd keep all together for now
Thanks for spotting this! |
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Context & Description
I got this exception when trying to use a hyphen in route. e.g.
assuming the fix it to replacing
-
to_
that makes compiler happy.