Skip to content

Commit

Permalink
Fix panic in path::{peek, tail, full} when URI is in authority or ast…
Browse files Browse the repository at this point in the history
…erisk form
  • Loading branch information
seanmonstar committed May 19, 2020
1 parent c983a2d commit 68e26af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/filters/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ fn path_and_query(route: &Route) -> PathAndQuery {
route
.uri()
.path_and_query()
.expect("server URIs should always have path_and_query")
.clone()
.cloned()
.unwrap_or_else(|| PathAndQuery::from_static(""))
}

/// Convenient way to chain multiple path filters together.
Expand Down
8 changes: 8 additions & 0 deletions tests/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ async fn full_path() {
// does not modify matching
let m = full_path.and(foo).and(bar);
assert!(warp::test::request().path("/foo/bar").matches(&m).await);

// doesn't panic on authority-form
let ex = warp::test::request()
.path("localhost:1234")
.filter(&full_path)
.await
.unwrap();
assert_eq!(ex.as_str(), "/");
}

#[tokio::test]
Expand Down

0 comments on commit 68e26af

Please sign in to comment.