aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2020-10-05 14:03:26 -0700
committerRichard Walters <rwalters@digitalstirling.com>2020-10-05 14:03:26 -0700
commitf95b6e2d031de4d59dafe094386da6d4a6074dad (patch)
tree18772e9de9afa60532150f14f4e766d7c20d684e
parentda7c16742836067e0a7e921679c54fe16b6fa7ae (diff)
Add tests for parsing hosts ending in dot
-rw-r--r--src/lib.rs11
-rw-r--r--test/src/UriTests.cpp6
2 files changed, 17 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 29e2c47..11b702e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -441,6 +441,17 @@ mod tests {
}
#[test]
+ fn parse_from_string_host_ends_in_dot() {
+ let uri = uriparse::URIReference::try_from("http://example.com./foo");
+ assert!(uri.is_ok());
+ let uri = uri.unwrap();
+ assert_eq!(
+ Some(&uriparse::Host::try_from("example.com.").unwrap()),
+ uri.host()
+ );
+ }
+
+ #[test]
fn parse_from_string_dont_misinterpret_colon_in_other_places_as_scheme_delimiter() {
let test_vectors = [
"//foo:bar@www.example.com/",
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp
index e3737c2..34e3483 100644
--- a/test/src/UriTests.cpp
+++ b/test/src/UriTests.cpp
@@ -292,6 +292,12 @@ TEST(UriTests, ParseFromStringSchemeMixedCase) {
}
}
+TEST(UriTests, ParseFromStringHostEndsInDot) {
+ Uri::Uri uri;
+ ASSERT_TRUE(uri.ParseFromString("http://example.com./foo"));
+ ASSERT_EQ("example.com.", uri.GetHost());
+}
+
TEST(UriTests, ParseFromStringUserInfoIllegalCharacters) {
const std::vector< std::string > testVectors{
{"//%X@www.example.com/"},