Skip to content

Commit 7981e00

Browse files
Remove a panic in normalize middleware (#1762)
Co-authored-by: Yuki Okushi <[email protected]>
1 parent 32d59ca commit 7981e00

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎CHANGES.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased - 2020-xx-xx
44
### Fixed
55
* Ensure `actix-http` dependency uses same `serde_urlencoded`.
6+
* Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`.
67

78

89
## 3.3.0 - 2020-11-25

‎src/middleware/normalize.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ where
137137
// so the change can not be deduced from the length comparison
138138
if path != original_path {
139139
let mut parts = head.uri.clone().into_parts();
140-
let pq = parts.path_and_query.as_ref().unwrap();
140+
let query = parts.path_and_query.as_ref().and_then(|pq| pq.query());
141141

142-
let path = if let Some(q) = pq.query() {
142+
let path = if let Some(q) = query {
143143
Bytes::from(format!("{}?{}", path, q))
144144
} else {
145145
Bytes::copy_from_slice(path.as_bytes())

0 commit comments

Comments
 (0)