mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-08 07:37:45 +00:00
Optimize type casting
This commit is contained in:
parent
213babb057
commit
bf783c2f3a
8 changed files with 32 additions and 28 deletions
10
src/main.rs
10
src/main.rs
|
@ -1,3 +1,7 @@
|
|||
// Global specifiers
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(clippy::pedantic, clippy::all)]
|
||||
|
||||
// Reference local files
|
||||
mod post;
|
||||
mod proxy;
|
||||
|
@ -48,10 +52,10 @@ impl<State: Clone + Send + Sync + 'static> Middleware<State> for NormalizePath {
|
|||
if path.ends_with('/') {
|
||||
Ok(next.run(request).await)
|
||||
} else {
|
||||
let normalized = if query != "" {
|
||||
format!("{}/?{}", path.replace("//", "/"), query)
|
||||
} else {
|
||||
let normalized = if query.is_empty() {
|
||||
format!("{}/", path.replace("//", "/"))
|
||||
} else {
|
||||
format!("{}/?{}", path.replace("//", "/"), query)
|
||||
};
|
||||
Ok(redirect(normalized))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue