diff options
author | adamw <adam@warski.org> | 2017-07-09 16:50:22 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-07-09 16:50:22 +0200 |
commit | 2e8f6d8b221f32e5df7663d296317886a43b1cf0 (patch) | |
tree | 82ab4df85c0c7d3416da892f0dd45003ed0c06e6 /core | |
parent | 18ed991eefd4ff541e722808f80a48d47df58a57 (diff) | |
download | sttp-2e8f6d8b221f32e5df7663d296317886a43b1cf0.tar.gz sttp-2e8f6d8b221f32e5df7663d296317886a43b1cf0.tar.bz2 sttp-2e8f6d8b221f32e5df7663d296317886a43b1cf0.zip |
More tests
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala index b967870..9c42f42 100644 --- a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala +++ b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala @@ -63,7 +63,8 @@ object UriInterpolator { case class Authority(s: Scheme, v: String = "") extends UriBuilder { override def parseS(s: String, doEncode: (String) => String): UriBuilder = { - // authority is terminated by /, ?, # or end of string (there might be other /, ?, # later on e.g. in the query) + // authority is terminated by /, ?, # or end of string (there might be + // other /, ?, # later on e.g. in the query) // see https://tools.ietf.org/html/rfc3986#section-3.2 s.split("[/\\?#]", 2) match { case Array(authorityFragment, rest) => @@ -90,11 +91,13 @@ object UriInterpolator { } override def build: String = { - // remove dangling "." which might occur due to optional authority fragments - val v2 = if (v.startsWith(".")) v.substring(1) else v - val v3 = if (v.endsWith(".")) v2.substring(0, v2.length - 1) else v2 + var vv = v + // remove dangling "." which might occur due to optional authority + // fragments + while (vv.startsWith(".")) vv = vv.substring(1) + while (vv.endsWith(".")) vv = vv.substring(0, vv.length - 1) - s.build + v3 + s.build + vv } private def append(x: String, doEncode: String => String): Authority = @@ -105,7 +108,8 @@ object UriInterpolator { extends UriBuilder { override def parseS(s: String, doEncode: (String) => String): UriBuilder = { - // path is terminated by ?, # or end of string (there might be other ?, # later on e.g. in the query) + // path is terminated by ?, # or end of string (there might be other + // ?, # later on e.g. in the query) // see https://tools.ietf.org/html/rfc3986#section-3.3 s.split("[\\?#]", 2) match { case Array(pathFragments, rest) => |