From ace710957641fcd2b9effd0c6c2ea89d53fe604e Mon Sep 17 00:00:00 2001 From: Tadas Dailyda Date: Sat, 17 Feb 2024 19:45:46 +0200 Subject: [PATCH] make trailing_slash non-optional on Router --- router/src/components/router.rs | 10 +++++----- router/src/components/routes.rs | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/router/src/components/router.rs b/router/src/components/router.rs index 4d931655d6..11453ec458 100644 --- a/router/src/components/router.rs +++ b/router/src/components/router.rs @@ -41,8 +41,8 @@ pub fn Router( #[prop(optional, into)] set_is_routing: Option>, /// How trailing slashes should be handled in [`Route`] paths. - #[prop(optional)] - trailing_slash: Option, + #[prop(default = TrailingSlash::default())] + trailing_slash: TrailingSlash, /// The `` should usually wrap your whole page. It can contain /// any elements, and should include a [`Routes`](crate::Routes) component somewhere /// to define and display [`Route`](crate::Route)s. @@ -96,7 +96,7 @@ pub(crate) struct RouterContextInner { id: usize, pub location: Location, pub base: RouteContext, - trailing_slash: Option, + trailing_slash: TrailingSlash, pub possible_routes: RefCell>>, #[allow(unused)] // used in CSR/hydrate base_path: String, @@ -133,7 +133,7 @@ impl RouterContext { pub(crate) fn new( base: Option<&'static str>, fallback: Option View>, - trailing_slash: Option, + trailing_slash: TrailingSlash, ) -> Self { cfg_if! { if #[cfg(any(feature = "csr", feature = "hydrate"))] { @@ -254,7 +254,7 @@ impl RouterContext { self.inner.id } - pub(crate) fn trailing_slash(&self) -> Option { + pub(crate) fn trailing_slash(&self) -> TrailingSlash { self.inner.trailing_slash.clone() } diff --git a/router/src/components/routes.rs b/router/src/components/routes.rs index 8ae273a089..dab47cb67c 100644 --- a/router/src/components/routes.rs +++ b/router/src/components/routes.rs @@ -372,9 +372,7 @@ fn inherit_settings(children: &mut [RouteDefinition], router: &RouterContext) { route_def_inherit( children, InheritProps { - trailing_slash: router - .trailing_slash() - .or(Some(TrailingSlash::default())), + trailing_slash: Some(router.trailing_slash()), }, ); }