use :.. instead of :...

This commit is contained in:
Evan Almloff committed 2023-07-18 16:34:27 -07:00
1 parent f2c4233ef4
commit 61e9fd9973
11 files changed
+15 -15

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ enum Route {
#[route("/")] #[route("/")]
Home {}, Home {},
// PageNotFound is a catch all route that will match any route and placing the matched segments in the route field // PageNotFound is a catch all route that will match any route and placing the matched segments in the route field
#[route("/:...route")] #[route("/:..route")]
PageNotFound { route: Vec<String> }, PageNotFound { route: Vec<String> },
} }
// ANCHOR_END: router // ANCHOR_END: router
+1 -1
View File
@@ -7,7 +7,7 @@ use dioxus_router::prelude::*;
#[rustfmt::skip] #[rustfmt::skip]
enum Route { enum Route {
// segments that start with :... are catch all segments // segments that start with :... are catch all segments
#[route("/blog/:...segments")] #[route("/blog/:..segments")]
BlogPost { BlogPost {
// You must include catch all segment in child variants // You must include catch all segment in child variants
segments: Vec<String>, segments: Vec<String>,
+1 -1
View File
@@ -26,7 +26,7 @@ enum Route {
#[end_layout] #[end_layout]
#[end_nest] #[end_nest]
#[end_layout] #[end_layout]
#[route("/:...route")] #[route("/:..route")]
PageNotFound { PageNotFound {
route: Vec<String>, route: Vec<String>,
}, },
+1 -1
View File
@@ -30,7 +30,7 @@ enum Route {
#[redirect("/", || Route::BlogList {})] #[redirect("/", || Route::BlogList {})]
#[redirect("/:name", |name: String| Route::BlogPost { name })] #[redirect("/:name", |name: String| Route::BlogPost { name })]
#[end_nest] #[end_nest]
#[route("/:...route")] #[route("/:..route")]
PageNotFound { PageNotFound {
route: Vec<String>, route: Vec<String>,
}, },
+1 -1
View File
@@ -11,7 +11,7 @@ enum Route {
#[route("/")] #[route("/")]
Home {}, Home {},
#[end_layout] #[end_layout]
#[route("/:...route")] #[route("/:..route")]
PageNotFound { route: Vec<String> }, PageNotFound { route: Vec<String> },
} }
// ANCHOR_END: router // ANCHOR_END: router
+1 -1
View File
@@ -7,7 +7,7 @@ use dioxus_router::prelude::*;
enum Route { enum Route {
#[route("/")] #[route("/")]
Home {}, Home {},
#[route("/:...route")] #[route("/:..route")]
PageNotFound { route: Vec<String> }, PageNotFound { route: Vec<String> },
} }
+1 -1
View File
@@ -11,7 +11,7 @@ enum Route {
#[route("/")] #[route("/")]
Home {}, Home {},
#[end_layout] #[end_layout]
#[route("/:...route")] #[route("/:..route")]
PageNotFound { route: Vec<String> }, PageNotFound { route: Vec<String> },
} }
// ANCHOR_END: router // ANCHOR_END: router
+1 -1
View File
@@ -30,7 +30,7 @@ enum Route {
#[redirect("/", || Route::BlogList {})] #[redirect("/", || Route::BlogList {})]
#[redirect("/:name", |name: String| Route::BlogPost { name })] #[redirect("/:name", |name: String| Route::BlogPost { name })]
#[end_nest] #[end_nest]
#[route("/:...route")] #[route("/:..route")]
PageNotFound { PageNotFound {
route: Vec<String>, route: Vec<String>,
}, },
+2 -2
View File
@@ -31,11 +31,11 @@ mod segment;
/// Route Segments: /// Route Segments:
/// 1. Static Segments: "/static" /// 1. Static Segments: "/static"
/// 2. Dynamic Segments: "/:dynamic" (where dynamic has a type that is FromStr in all child Variants) /// 2. Dynamic Segments: "/:dynamic" (where dynamic has a type that is FromStr in all child Variants)
/// 3. Catch all Segments: "/:...segments" (where segments has a type that is FromSegments in all child Variants) /// 3. Catch all Segments: "/:..segments" (where segments has a type that is FromSegments in all child Variants)
/// 4. Query Segments: "/?:query" (where query has a type that is FromQuery in all child Variants) /// 4. Query Segments: "/?:query" (where query has a type that is FromQuery in all child Variants)
/// ///
/// Routes are matched: /// Routes are matched:
/// 1. By there specificity this order: Query Routes ("/?:query"), Static Routes ("/route"), Dynamic Routes ("/:route"), Catch All Routes ("/:...route") /// 1. By there specificity this order: Query Routes ("/?:query"), Static Routes ("/route"), Dynamic Routes ("/:route"), Catch All Routes ("/:..route")
/// 2. By the order they are defined in the enum /// 2. By the order they are defined in the enum
/// ///
/// All features: /// All features:
+3 -3
View File
@@ -126,7 +126,7 @@ impl Route {
None => { None => {
return Err(syn::Error::new_spanned( return Err(syn::Error::new_spanned(
variant.clone(), variant.clone(),
"Routable variants with a #[child(...)] attribute must have a field named \"child\" or a field with a #[child] attribute", "Routable variants with a #[child(..)] attribute must have a field named \"child\" or a field with a #[child] attribute",
)); ));
} }
} }
@@ -134,14 +134,14 @@ impl Route {
_ => { _ => {
return Err(syn::Error::new_spanned( return Err(syn::Error::new_spanned(
variant.clone(), variant.clone(),
"Routable variants with a #[child(...)] attribute must have named fields", "Routable variants with a #[child(..)] attribute must have named fields",
)) ))
} }
} }
} else { } else {
return Err(syn::Error::new_spanned( return Err(syn::Error::new_spanned(
variant.clone(), variant.clone(),
"Routable variants must either have a #[route(...)] attribute or a #[child(...)] attribute", "Routable variants must either have a #[route(..)] attribute or a #[child(..)] attribute",
)); ));
} }
} }
+2 -2
View File
@@ -150,10 +150,10 @@ pub fn parse_route_segments<'a>(
while let Some(segment) = iterator.next() { while let Some(segment) = iterator.next() {
if let Some(segment) = segment.strip_prefix(':') { if let Some(segment) = segment.strip_prefix(':') {
let spread = segment.starts_with("..."); let spread = segment.starts_with("..");
let ident = if spread { let ident = if spread {
segment[3..].to_string() segment[2..].to_string()
} else { } else {
segment.to_string() segment.to_string()
}; };