Parse redirects in the same order they appear in (#2650)

* Parse redirects in the same order they appear in
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-25 17:47:38 -07:00
1 parent c6a2e5b6c8
commit 443b9a4af6
4 files changed
+120 -51

No files matched your search

+7 -8
View File
@@ -8,6 +8,7 @@ use crate::{
redirect::Redirect,
route::{Route, RouteType},
segment::{static_segment_idx, RouteSegment},
RouteEndpoint,
};
#[derive(Debug, Clone, Default)]
@@ -97,15 +98,13 @@ impl<'a> RouteTree<'a> {
.expect("Cannot get children of non static or nest segment")
}
pub(crate) fn new(routes: &'a [Route], nests: &'a [Nest], redirects: &'a [Redirect]) -> Self {
let routes = routes
pub(crate) fn new(endpoints: &'a [RouteEndpoint], nests: &'a [Nest]) -> Self {
let routes = endpoints
.iter()
.map(|route| PathIter::new_route(route, nests))
.chain(
redirects
.iter()
.map(|redirect| PathIter::new_redirect(redirect, nests)),
)
.map(|endpoint| match endpoint {
RouteEndpoint::Route(route) => PathIter::new_route(route, nests),
RouteEndpoint::Redirect(redirect) => PathIter::new_redirect(redirect, nests),
})
.collect::<Vec<_>>();
let mut myself = Self::default();