From 54722c73e472178f96416fbff8929d9a699d3e03 Mon Sep 17 00:00:00 2001 From: adamw Date: Mon, 27 Nov 2017 11:36:45 +0100 Subject: Properly encoding ipv6 addresses --- .../test/scala/com/softwaremill/sttp/UriTests.scala | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'core/src/test/scala') diff --git a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala index 3c54fd2..23fe3d5 100644 --- a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala +++ b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala @@ -50,8 +50,7 @@ class UriTests extends FunSuite with Matchers { "http://example.com#f:g/h%20i", Uri("http", None, "example.com", None, List("key=value"), Nil, None) -> "http://example.com/key=value", - Uri("http", "www.mikołak.net") -> - "http://www.xn--mikoak-6db.net" + Uri("2001:db8::ff00:42:8329", 8080) -> "http://[2001:db8::ff00:42:8329]:8080" ) for { @@ -112,6 +111,22 @@ class UriTests extends FunSuite with Matchers { } } + val hostTestData = List( + "www.mikołak.net" -> "http://www.xn--mikoak-6db.net", + "192.168.1.0" -> "http://192.168.1.0", + "::1" -> "http://[::1]", + "2001:db8::ff00:42:8329" -> "http://[2001:db8::ff00:42:8329]", + "2001:0db8:0000:0000:0000:ff00:0042:8329" -> "http://[2001:0db8:0000:0000:0000:ff00:0042:8329]" + ) + + for { + (host, expected) <- hostTestData + } { + test(s"host $host should serialize to $expected") { + Uri(host).toString should be(s"$expected") + } + } + test("should convert from java URI") { val uriAsString = "https://sub.example.com:8080/a/b/xyz?p1=v1&p2=v2#f" Uri(URI.create(uriAsString)).toString should be(uriAsString) -- cgit v1.2.3