mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
parent
6166f6edbd
commit
1fce8931ab
2 changed files with 20 additions and 1 deletions
|
@ -104,6 +104,11 @@ impl<T: AsPath> PossibleRouteMatch for StaticSegment<T> {
|
|||
}
|
||||
}
|
||||
|
||||
// if we still have remaining, unmatched characters in this segment, it was not a match
|
||||
if this.next().is_some() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// build the match object
|
||||
// the remaining is built from the path in, with the slice moved
|
||||
// by the length of this match
|
||||
|
|
|
@ -156,6 +156,7 @@ mod tests {
|
|||
matching::MatchParams, MatchInterface, PathSegment, StaticSegment,
|
||||
WildcardSegment,
|
||||
};
|
||||
use either_of::Either;
|
||||
use tachys::renderer::dom::Dom;
|
||||
|
||||
#[test]
|
||||
|
@ -164,8 +165,11 @@ mod tests {
|
|||
Routes::<_, Dom>::new(NestedRoute::new(StaticSegment("/"), || ()));
|
||||
let matched = routes.match_route("/");
|
||||
assert!(matched.is_some());
|
||||
// this case seems like it should match, but implementing it interferes with
|
||||
// handling trailing slash requirements accurately -- paths for the root are "/",
|
||||
// not "", in any case
|
||||
let matched = routes.match_route("");
|
||||
assert!(matched.is_some());
|
||||
assert!(matched.is_none());
|
||||
let (base, paths) = routes.generate_routes();
|
||||
assert_eq!(base, None);
|
||||
let paths = paths.into_iter().map(|g| g.segments).collect::<Vec<_>>();
|
||||
|
@ -204,6 +208,16 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn does_not_match_route_unless_full_param_matches() {
|
||||
let routes = Routes::<_, Dom>::new((
|
||||
NestedRoute::new(StaticSegment("/property-api"), || ()),
|
||||
NestedRoute::new(StaticSegment("/property"), || ()),
|
||||
));
|
||||
let matched = routes.match_route("/property").unwrap();
|
||||
assert!(matches!(matched, Either::Right(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn does_not_match_incomplete_route() {
|
||||
let routes: Routes<_, Dom> =
|
||||
|
|
Loading…
Reference in a new issue