Change NormalizePath to append trailing slash

This commit is contained in:
Stephen Eckels 2020-03-28 17:07:39 -04:00 committed by GitHub
parent fcb1dec235
commit da83d1a820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -74,9 +74,13 @@ where
fn call(&mut self, mut req: ServiceRequest) -> Self::Future {
let head = req.head_mut();
let path = head.uri.path();
// always add trailing slash, might be an extra one
let path = head.uri.path().to_string() + "/";
let original_len = path.len();
let path = self.merge_slash.replace_all(path, "/");
// normalize multiple /'s to one /
let path = self.merge_slash.replace_all(&path, "/");
if original_len != path.len() {
let mut parts = head.uri.clone().into_parts();