这是indexloc提供的服务,不要输入任何密码
Skip to content

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

Merged
merged 5 commits into from
Nov 16, 2024

Conversation

chenhunghan
Copy link
Contributor

Context & Description

I got this exception when trying to use a hyphen in route. e.g.

src/routes/openid-conntect/index.rs
Screenshot 2024-11-16 at 13 45 17

assuming the fix it to replacing - to _ that makes compiler happy.

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
@@ -30,7 +30,7 @@ impl AxumInfo {
let module_import = module
.as_str()
.to_string()
.replace('/', "_")
.replace(['/', '-'], "_")
Copy link
Member

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_

@@ -186,6 +186,19 @@ mod tests {
assert_eq!(dyn_info.module_import, "dyn_posts");
}

#[test]
fn should_handle_hyphen() {
Copy link
Member

@Valerioageno Valerioageno Nov 16, 2024

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

@Valerioageno
Copy link
Member

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>
@Valerioageno Valerioageno merged commit f0a4541 into tuono-labs:main Nov 16, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants