mirror of
https://github.com/NetworkCats/rustyip.git
synced 2026-11-13 16:17:46 +00:00
fix: redirect to root path on empty search query
This commit is contained in:
+14
-4
@@ -454,8 +454,10 @@ pub async fn root_redirect(
|
||||
let mut redirect_path = format!("/{}", locale.tag());
|
||||
|
||||
if let Some(ref ip) = query.ip {
|
||||
redirect_path.push_str("?ip=");
|
||||
redirect_path.push_str(&urlencoding::encode(ip));
|
||||
if !ip.trim().is_empty() {
|
||||
redirect_path.push_str("?ip=");
|
||||
redirect_path.push_str(&urlencoding::encode(ip));
|
||||
}
|
||||
}
|
||||
|
||||
Redirect::temporary(&redirect_path).into_response()
|
||||
@@ -467,8 +469,10 @@ pub async fn root_trailing_slash(
|
||||
) -> Response {
|
||||
let mut redirect_path = format!("/{lang}");
|
||||
if let Some(ref ip) = query.ip {
|
||||
redirect_path.push_str("?ip=");
|
||||
redirect_path.push_str(&urlencoding::encode(ip));
|
||||
if !ip.trim().is_empty() {
|
||||
redirect_path.push_str("?ip=");
|
||||
redirect_path.push_str(&urlencoding::encode(ip));
|
||||
}
|
||||
}
|
||||
Redirect::permanent(&redirect_path).into_response()
|
||||
}
|
||||
@@ -512,6 +516,12 @@ pub async fn root(
|
||||
};
|
||||
}
|
||||
|
||||
if let Some(ref ip_str) = query.ip {
|
||||
if ip_str.trim().is_empty() {
|
||||
return Redirect::temporary(&format!("/{}", locale.tag())).into_response();
|
||||
}
|
||||
}
|
||||
|
||||
let query_str = query.ip.clone().unwrap_or_default();
|
||||
|
||||
let ip = match resolve_ip(&headers, &query, state.dev_mode) {
|
||||
|
||||
Reference in New Issue
Block a user