rest-server: cleanup unreadable code

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2023-01-24 11:41:52 +01:00
parent a1119a3e63
commit 28ba2016e5

View File

@ -89,22 +89,19 @@ impl ApiConfig {
self.router.find_method(components, method, uri_param)
}
pub(crate) fn find_alias(&self, components: &[&str]) -> PathBuf {
let mut prefix = String::new();
pub(crate) fn find_alias(&self, mut components: &[&str]) -> PathBuf {
let mut filename = self.basedir.clone();
let comp_len = components.len();
if comp_len >= 1 {
prefix.push_str(components[0]);
if let Some(subdir) = self.aliases.get(&prefix) {
if components.is_empty() {
return filename;
}
if let Some(subdir) = self.aliases.get(components[0]) {
filename.push(subdir);
components
.iter()
.skip(1)
.for_each(|comp| filename.push(comp));
} else {
components.iter().for_each(|comp| filename.push(comp));
}
components = &components[1..];
}
filename.extend(components);
filename
}