move Redirect::compute_target to standalone function in web_server.rs

This commit is contained in:
Alex Auvolat
2025-01-04 18:22:42 +01:00
parent 6ccfbb2986
commit 22487ceddf
2 changed files with 26 additions and 28 deletions
-25
View File
@@ -85,31 +85,6 @@ mod v08 {
pub replace_key: Option<String>,
}
impl Redirect {
pub fn compute_target(&self, suffix: Option<&str>) -> String {
let mut res = String::new();
if let Some(hostname) = &self.hostname {
if let Some(protocol) = &self.protocol {
res.push_str(protocol);
res.push_str("://");
} else {
res.push_str("//");
}
res.push_str(hostname);
}
res.push('/');
if let Some(replace_key_prefix) = &self.replace_key_prefix {
res.push_str(replace_key_prefix);
if let Some(suffix) = suffix {
res.push_str(suffix)
}
} else if let Some(replace_key) = &self.replace_key {
res.push_str(replace_key)
}
res
}
}
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
pub struct CorsRule {
pub id: Option<String>,