Path normalization does not trim preceding slashes of uri
jhoolmans opened this issue · comments
Jeroen Hoolmans commented
Bug Report
Versions:
tower-http = "0.4.0"
(also in master)
Description
For normalization of the path I expected it to trim the slashes on the end and beginning.
Some requests have double preceding slashes which causes for routes to return 404 status code.
#[tokio::main]
async fn main() {
let app = NormalizePath::trim_trailing_slash(
Router::new()
.route("/", get(|| async { "index" }))
.route("/foo", get(|| async { "foo" }))
);
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.expect("Failed to start axum server");
}
To test:
curl http://localhost:3000//foo
returns 404