diff options
| author | Fuwn <[email protected]> | 2025-07-08 05:16:56 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-07-08 05:16:56 +0000 |
| commit | 1381dfc93851550fe05d24d69401b1ba3af1add9 (patch) | |
| tree | a8ea7ee0143adf8df771b8f49cb192f8bd808eb2 | |
| parent | feat(router): Add missing trailing slash corrector (diff) | |
| download | windmark-1381dfc93851550fe05d24d69401b1ba3af1add9.tar.xz windmark-1381dfc93851550fe05d24d69401b1ba3af1add9.zip | |
refactor(RouterOption): Rename trailing slash trimming option
| -rw-r--r-- | examples/fix_path.rs | 2 | ||||
| -rw-r--r-- | src/router.rs | 4 | ||||
| -rw-r--r-- | src/router_option.rs | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/examples/fix_path.rs b/examples/fix_path.rs index 95761ea..6ea8f9e 100644 --- a/examples/fix_path.rs +++ b/examples/fix_path.rs @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { .set_private_key_file("windmark_private.pem") .set_certificate_file("windmark_public.pem") .add_options(&[ - windmark::router_option::RouterOption::TrimTrailingSlashes, + windmark::router_option::RouterOption::RemoveExtraTrailingSlash, windmark::router_option::RouterOption::AddMissingTrailingSlash, ]) .mount( diff --git a/src/router.rs b/src/router.rs index 461d698..6ae33b0 100644 --- a/src/router.rs +++ b/src/router.rs @@ -424,7 +424,9 @@ impl Router { let mut route = self.routes.at(&path); if route.is_err() { - if self.options.contains(&RouterOption::TrimTrailingSlashes) + if self + .options + .contains(&RouterOption::RemoveExtraTrailingSlash) && path.ends_with('/') && path != "/" { diff --git a/src/router_option.rs b/src/router_option.rs index 2672a42..d3d0bb9 100644 --- a/src/router_option.rs +++ b/src/router_option.rs @@ -3,7 +3,7 @@ pub enum RouterOption { /// Trim trailing slashes from the URL path if it is present and a route /// match exists - TrimTrailingSlashes, + RemoveExtraTrailingSlash, /// Add a trailing slash to the URL path if it is missing and a route /// match exists AddMissingTrailingSlash, |