Skip to content

Commit

Permalink
Remove a panic in normalize middleware (#1762)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
  • Loading branch information
maciejhirsz and JohnTitor authored Dec 1, 2020
1 parent 32d59ca commit 7981e00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased - 2020-xx-xx
### Fixed
* Ensure `actix-http` dependency uses same `serde_urlencoded`.
* Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`.


## 3.3.0 - 2020-11-25
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ where
// so the change can not be deduced from the length comparison
if path != original_path {
let mut parts = head.uri.clone().into_parts();
let pq = parts.path_and_query.as_ref().unwrap();
let query = parts.path_and_query.as_ref().and_then(|pq| pq.query());

let path = if let Some(q) = pq.query() {
let path = if let Some(q) = query {
Bytes::from(format!("{}?{}", path, q))
} else {
Bytes::copy_from_slice(path.as_bytes())
Expand Down

0 comments on commit 7981e00

Please sign in to comment.