mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
use :.. instead of :...
This commit is contained in:
parent
f2c4233ef4
commit
61e9fd9973
11 changed files with 15 additions and 15 deletions
|
@ -8,7 +8,7 @@ enum Route {
|
|||
#[route("/")]
|
||||
Home {},
|
||||
// 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> },
|
||||
}
|
||||
// ANCHOR_END: router
|
||||
|
|
|
@ -7,7 +7,7 @@ use dioxus_router::prelude::*;
|
|||
#[rustfmt::skip]
|
||||
enum Route {
|
||||
// segments that start with :... are catch all segments
|
||||
#[route("/blog/:...segments")]
|
||||
#[route("/blog/:..segments")]
|
||||
BlogPost {
|
||||
// You must include catch all segment in child variants
|
||||
segments: Vec<String>,
|
||||
|
|
|
@ -26,7 +26,7 @@ enum Route {
|
|||
#[end_layout]
|
||||
#[end_nest]
|
||||
#[end_layout]
|
||||
#[route("/:...route")]
|
||||
#[route("/:..route")]
|
||||
PageNotFound {
|
||||
route: Vec<String>,
|
||||
},
|
||||
|
|
|
@ -30,7 +30,7 @@ enum Route {
|
|||
#[redirect("/", || Route::BlogList {})]
|
||||
#[redirect("/:name", |name: String| Route::BlogPost { name })]
|
||||
#[end_nest]
|
||||
#[route("/:...route")]
|
||||
#[route("/:..route")]
|
||||
PageNotFound {
|
||||
route: Vec<String>,
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ enum Route {
|
|||
#[route("/")]
|
||||
Home {},
|
||||
#[end_layout]
|
||||
#[route("/:...route")]
|
||||
#[route("/:..route")]
|
||||
PageNotFound { route: Vec<String> },
|
||||
}
|
||||
// ANCHOR_END: router
|
||||
|
|
|
@ -7,7 +7,7 @@ use dioxus_router::prelude::*;
|
|||
enum Route {
|
||||
#[route("/")]
|
||||
Home {},
|
||||
#[route("/:...route")]
|
||||
#[route("/:..route")]
|
||||
PageNotFound { route: Vec<String> },
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ enum Route {
|
|||
#[route("/")]
|
||||
Home {},
|
||||
#[end_layout]
|
||||
#[route("/:...route")]
|
||||
#[route("/:..route")]
|
||||
PageNotFound { route: Vec<String> },
|
||||
}
|
||||
// ANCHOR_END: router
|
||||
|
|
|
@ -30,7 +30,7 @@ enum Route {
|
|||
#[redirect("/", || Route::BlogList {})]
|
||||
#[redirect("/:name", |name: String| Route::BlogPost { name })]
|
||||
#[end_nest]
|
||||
#[route("/:...route")]
|
||||
#[route("/:..route")]
|
||||
PageNotFound {
|
||||
route: Vec<String>,
|
||||
},
|
||||
|
|
|
@ -31,11 +31,11 @@ mod segment;
|
|||
/// Route Segments:
|
||||
/// 1. Static Segments: "/static"
|
||||
/// 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)
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
/// All features:
|
||||
|
|
|
@ -126,7 +126,7 @@ impl Route {
|
|||
None => {
|
||||
return Err(syn::Error::new_spanned(
|
||||
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(
|
||||
variant.clone(),
|
||||
"Routable variants with a #[child(...)] attribute must have named fields",
|
||||
"Routable variants with a #[child(..)] attribute must have named fields",
|
||||
))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Err(syn::Error::new_spanned(
|
||||
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",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,10 +150,10 @@ pub fn parse_route_segments<'a>(
|
|||
|
||||
while let Some(segment) = iterator.next() {
|
||||
if let Some(segment) = segment.strip_prefix(':') {
|
||||
let spread = segment.starts_with("...");
|
||||
let spread = segment.starts_with("..");
|
||||
|
||||
let ident = if spread {
|
||||
segment[3..].to_string()
|
||||
segment[2..].to_string()
|
||||
} else {
|
||||
segment.to_string()
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue