diff options
| -rw-r--r-- | src/route.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/route.rs b/src/route.rs index 171952c..1e2f29c 100644 --- a/src/route.rs +++ b/src/route.rs @@ -43,8 +43,39 @@ pub fn track_mount<F, R>( { if !description.starts_with('-') { (*ROUTES.lock().unwrap()) - .insert(route.to_string(), Route::new(&description.replacen('-', "", 1))); + .insert(route.to_string(), Route::new(description)); } router.mount(route, handler); } + +#[cfg(test)] +mod tests { + use super::{ROUTES, track_mount}; + + #[test] + fn track_mount_preserves_internal_hyphens_in_public_descriptions() { + let mut router = windmark::router::Router::new(); + + ROUTES.lock().unwrap().clear(); + track_mount( + &mut router, + "/finger", + "Finger-to-Gemini Gateway", + |_context| async { + windmark::response::Response::success("ok".to_string()) + }, + ); + + let stored_description = ROUTES + .lock() + .unwrap() + .get("/finger") + .map(|route| route.description.clone()); + + assert_eq!( + stored_description, + Some("Finger-to-Gemini Gateway".to_string()) + ); + } +} |