Skip to content

Commit

Permalink
make trailing_slash non-optional on Router
Browse files Browse the repository at this point in the history
  • Loading branch information
skirsdeda committed Feb 17, 2024
1 parent 61351ee commit ace7109
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions router/src/components/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub fn Router(
#[prop(optional, into)]
set_is_routing: Option<SignalSetter<bool>>,
/// How trailing slashes should be handled in [`Route`] paths.
#[prop(optional)]
trailing_slash: Option<TrailingSlash>,
#[prop(default = TrailingSlash::default())]
trailing_slash: TrailingSlash,
/// The `<Router/>` 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.
Expand Down Expand Up @@ -96,7 +96,7 @@ pub(crate) struct RouterContextInner {
id: usize,
pub location: Location,
pub base: RouteContext,
trailing_slash: Option<TrailingSlash>,
trailing_slash: TrailingSlash,
pub possible_routes: RefCell<Option<Vec<Branch>>>,
#[allow(unused)] // used in CSR/hydrate
base_path: String,
Expand Down Expand Up @@ -133,7 +133,7 @@ impl RouterContext {
pub(crate) fn new(
base: Option<&'static str>,
fallback: Option<fn() -> View>,
trailing_slash: Option<TrailingSlash>,
trailing_slash: TrailingSlash,
) -> Self {
cfg_if! {
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
Expand Down Expand Up @@ -254,7 +254,7 @@ impl RouterContext {
self.inner.id
}

pub(crate) fn trailing_slash(&self) -> Option<TrailingSlash> {
pub(crate) fn trailing_slash(&self) -> TrailingSlash {
self.inner.trailing_slash.clone()
}

Expand Down
4 changes: 1 addition & 3 deletions router/src/components/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
},
);
}
Expand Down

0 comments on commit ace7109

Please sign in to comment.