web_ui_path fixes

This commit is contained in:
euzu
2025-08-05 14:20:13 +02:00
parent bb79c201c4
commit 420912a79d
11 changed files with 45 additions and 29 deletions
+14 -1
View File
@@ -124,6 +124,19 @@ pub fn get_base_url_from_str(url: &str) -> Option<String> {
pub fn concat_path(first: &str, second: &str) -> String {
let first = first.trim_end_matches('/');
let second = second.trim_start_matches('/');
match (first.is_empty(), second.is_empty()) {
(true, true) => String::new(),
(true, false) => second.to_string(),
(false, true) => first.to_string(),
(false, false) => format!("{first}/{second}"),
}
}
format!("{first}/{second}")
pub fn concat_path_leading_slash(first: &str, second: &str) -> String {
let path = concat_path(first, second);
if path.is_empty() {
return path;
}
let path = path.trim_start_matches('/');
format!("/{path}")
}