Compare commits
1 Commits
b0f0038b24
...
2603c835c6
| Author | SHA1 | Date | |
|---|---|---|---|
| 2603c835c6 |
@@ -130,6 +130,28 @@ impl PageServer {
|
|||||||
.and_then(|x| x.to_str().ok())
|
.and_then(|x| x.to_str().ok())
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
|
||||||
|
// Normalize url with redirect
|
||||||
|
if route.ends_with('/') {
|
||||||
|
let new_route = route.trim_end_matches('/');
|
||||||
|
|
||||||
|
trace!(
|
||||||
|
message = "Redirecting route",
|
||||||
|
route,
|
||||||
|
new_route,
|
||||||
|
addr = ?addr.addr,
|
||||||
|
user_agent = ua,
|
||||||
|
device_type = ?client_info.device_type
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut headers = HeaderMap::with_capacity(2);
|
||||||
|
headers.append(
|
||||||
|
header::LOCATION,
|
||||||
|
HeaderValue::from_str(&format!("/{new_route}")).unwrap(),
|
||||||
|
);
|
||||||
|
headers.append("Accept-CH", HeaderValue::from_static("Sec-CH-UA-Mobile"));
|
||||||
|
return (StatusCode::PERMANENT_REDIRECT, headers).into_response();
|
||||||
|
}
|
||||||
|
|
||||||
trace!(
|
trace!(
|
||||||
message = "Serving route",
|
message = "Serving route",
|
||||||
route,
|
route,
|
||||||
|
|||||||
Reference in New Issue
Block a user