mirror of
https://github.com/leptos-rs/leptos
synced 2024-09-20 06:21:57 +00:00
fix: properly handle trailing /
in more routes (#1900)
This commit is contained in:
parent
4a4e16c206
commit
0d6ddfb71e
1 changed files with 5 additions and 8 deletions
|
@ -57,13 +57,14 @@ impl Matcher {
|
||||||
let loc_len = loc_segments.len();
|
let loc_len = loc_segments.len();
|
||||||
let len_diff: i32 = loc_len as i32 - self.len as i32;
|
let len_diff: i32 = loc_len as i32 - self.len as i32;
|
||||||
|
|
||||||
|
let trailing_iter = location.chars().rev().take_while(|n| *n == '/');
|
||||||
|
|
||||||
// quick path: not a match if
|
// quick path: not a match if
|
||||||
// 1) matcher has add'l segments not found in location
|
// 1) matcher has add'l segments not found in location
|
||||||
// 2) location has add'l segments, there's no splat, and partial matches not allowed
|
// 2) location has add'l segments, there's no splat, and partial matches not allowed
|
||||||
if loc_len < self.len
|
if loc_len < self.len
|
||||||
|| (len_diff > 0 && self.splat.is_none() && !self.partial)
|
|| (len_diff > 0 && self.splat.is_none() && !self.partial)
|
||||||
|| (self.splat.is_none()
|
|| (self.splat.is_none() && trailing_iter.clone().count() > 1)
|
||||||
&& location.split('/').count() > (2 * (loc_segments.len() + 1)))
|
|
||||||
{
|
{
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -95,12 +96,8 @@ impl Matcher {
|
||||||
};
|
};
|
||||||
|
|
||||||
// add trailing slashes to splat
|
// add trailing slashes to splat
|
||||||
let trailing_slashes = location
|
let trailing_slashes =
|
||||||
.chars()
|
trailing_iter.skip(1).collect::<String>();
|
||||||
.rev()
|
|
||||||
.take_while(|n| *n == '/')
|
|
||||||
.skip(1)
|
|
||||||
.collect::<String>();
|
|
||||||
value.push_str(&trailing_slashes);
|
value.push_str(&trailing_slashes);
|
||||||
|
|
||||||
params.insert(splat.into(), value);
|
params.insert(splat.into(), value);
|
||||||
|
|
Loading…
Reference in a new issue