fix: auth not works with --path-prefix (#138)

close #137
This commit is contained in:
sigoden
2022-10-08 09:14:42 +08:00
committed by GitHub
parent 3b3ea718d9
commit dbf2de9cb9
2 changed files with 18 additions and 1 deletions

View File

@@ -132,7 +132,12 @@ impl GuardType {
}
fn sanitize_path(path: &str, uri_prefix: &str) -> String {
encode_uri(&format!("{}{}", uri_prefix, path.trim_matches('/')))
let new_path = match (uri_prefix, path) {
("/", "/") => "/".into(),
(_, "/") => uri_prefix.trim_end_matches('/').into(),
_ => format!("{}{}", uri_prefix, path.trim_matches('/')),
};
encode_uri(&new_path)
}
fn walk_path(path: &str) -> impl Iterator<Item = &str> {