From d3a64dc5abe1fd86a0dd18061221a9e4102ebb57 Mon Sep 17 00:00:00 2001 From: Gabriel Feron Date: Tue, 30 Oct 2018 16:44:52 +0100 Subject: [PATCH] Fix partial equality for URI with terminating questionmark --- src/uri/mod.rs | 4 ++++ src/uri/tests.rs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/uri/mod.rs b/src/uri/mod.rs index 65d56e23..925d9943 100644 --- a/src/uri/mod.rs +++ b/src/uri/mod.rs @@ -937,6 +937,10 @@ impl PartialEq for Uri { } if let Some(query) = self.query() { + if other.len() == 0 { + return query.len() == 0; + } + if other[0] != b'?' { return false; } diff --git a/src/uri/tests.rs b/src/uri/tests.rs index 1fe8d8b4..f580e89a 100644 --- a/src/uri/tests.rs +++ b/src/uri/tests.rs @@ -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); +}