aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-07-15 12:14:27 +0200
committeradamw <adam@warski.org>2017-07-15 12:14:27 +0200
commitaeea53b49309cbfcbfcdf8a466c3cde418bd58df (patch)
treedd1546ffabc80185118ce445089ba5ebdb8e8e16 /core/src
parent8d9145a04cdd21a471fba61fc19203759b95514d (diff)
downloadsttp-aeea53b49309cbfcbfcdf8a466c3cde418bd58df.tar.gz
sttp-aeea53b49309cbfcbfcdf8a466c3cde418bd58df.tar.bz2
sttp-aeea53b49309cbfcbfcdf8a466c3cde418bd58df.zip
Better URI interpolator
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala
index d00619d..1216a1e 100644
--- a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala
+++ b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala
@@ -52,7 +52,21 @@ object UriInterpolator {
}
}
- override def parseE(e: Any): UriBuilder = parseE_asEncodedS_skipNone(e)
+ override def parseE(e: Any): UriBuilder = {
+ def encodeIfNotInitialEndpoint(s: String) = {
+ // special case: when this is the first expression, contains a complete schema with :// and nothing is yet parsed
+ // not escaping the contents
+ if (v.isEmpty && s.contains("://")) s else encode(s)
+ }
+
+ e match {
+ case s: String => parseS(encodeIfNotInitialEndpoint(s))
+ case None => this
+ case null => this
+ case Some(x) => parseE(x)
+ case x => parseS(encodeIfNotInitialEndpoint(x.toString))
+ }
+ }
private def append(x: String): Scheme = Scheme(v + x)