Skip to content

Commit

Permalink
fix: panic if add_route gets a path with a trailing slash
Browse files Browse the repository at this point in the history
This will get surfaced by tests
  • Loading branch information
msfjarvis committed Dec 30, 2024
1 parent aed7e06 commit 13151a2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/router_ext.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/// Naive macro to add a route and its trailing slash variant to the router
macro_rules! add_route {
($router:ident, $route:literal) => {
assert!(
!$route.ends_with("/"),
"URLs passed to add_route must not end in /"
);
$router.insert($route, ()).unwrap();
$router.insert(concat!($route, "/"), ()).unwrap();
};
Expand Down

0 comments on commit 13151a2

Please sign in to comment.