Remove leading / in keys; better delimiter handling

This commit is contained in:
Alex Auvolat 2020-04-24 22:28:15 +02:00
parent be4831d768
commit e3203f998b
2 changed files with 8 additions and 3 deletions

View file

@ -78,6 +78,7 @@ async fn handler_inner(
let (bucket, key) = match path.find('/') {
Some(i) => {
let (bucket, key) = path.split_at(i);
let key = key.trim_start_matches('/');
(bucket, Some(key))
}
None => (path, None),

View file

@ -55,9 +55,13 @@ pub async fn handle_list(
break;
}
};
let delimited_key = match relative_key.find(delimiter) {
Some(i) => relative_key.split_at(i).1,
None => &relative_key,
let delimited_key = if delimiter.len() > 0 {
match relative_key.find(delimiter) {
Some(i) => relative_key.split_at(i).0,
None => &relative_key,
}
} else {
&relative_key
};
let delimited_key = delimited_key.to_string();
let new_info = match result.get(&delimited_key) {