Remove leading / in keys; better delimiter handling

This commit is contained in:
Alex 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('/') { let (bucket, key) = match path.find('/') {
Some(i) => { Some(i) => {
let (bucket, key) = path.split_at(i); let (bucket, key) = path.split_at(i);
let key = key.trim_start_matches('/');
(bucket, Some(key)) (bucket, Some(key))
} }
None => (path, None), None => (path, None),

View file

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