Skip to content

Commit

Permalink
Fix partial equality for URI with terminating questionmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Feron committed Oct 30, 2018
1 parent 4e21f48 commit 428bd85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/uri/mod.rs
Expand Up @@ -937,6 +937,10 @@ impl PartialEq<str> for Uri {
}

if let Some(query) = self.query() {
if other.len() == 0 {
return query.len() == 0;
}

if other[0] != b'?' {
return false;
}
Expand Down
8 changes: 8 additions & 0 deletions src/uri/tests.rs
Expand Up @@ -461,3 +461,11 @@ fn test_authority_uri_parts_round_trip() {
assert_eq!(uri2, s);
assert_eq!(uri2.to_string(), s);
}

#[test]
fn test_partial_eq_path_with_terminating_questionmark() {
let a = "/path";
let uri = Uri::from_str("/path?").expect("first parse");

assert_eq!(uri, a);
}

0 comments on commit 428bd85

Please sign in to comment.