mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Fix basename handling in router (#2297)
This commit is contained in:
parent
61efc8042e
commit
5181e1aca7
@ -1,6 +1,4 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::utils::{base_url, strip_slash_suffix};
|
||||
use crate::utils::strip_slash_suffix;
|
||||
use crate::Routable;
|
||||
|
||||
// re-export Router because the macro needs to access it
|
||||
@ -8,16 +6,9 @@ pub type Router = route_recognizer::Router<String>;
|
||||
|
||||
/// Build a `route_recognizer::Router` from a `Routable` type.
|
||||
pub fn build_router<R: Routable>() -> Router {
|
||||
let base = base_url();
|
||||
let mut router = Router::new();
|
||||
R::routes().iter().for_each(|path| {
|
||||
let route = match base {
|
||||
Some(ref base) => Cow::from(format!("{}{}", base, path)),
|
||||
None => (*path).into(),
|
||||
};
|
||||
|
||||
let stripped_route = strip_slash_suffix(&route);
|
||||
|
||||
let stripped_route = strip_slash_suffix(path);
|
||||
router.add(stripped_route, path.to_string());
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user