From aeea53b49309cbfcbfcdf8a466c3cde418bd58df Mon Sep 17 00:00:00 2001 From: adamw Date: Sat, 15 Jul 2017 12:14:27 +0200 Subject: Better URI interpolator --- .../scala/com/softwaremill/sttp/UriInterpolator.scala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'core/src') 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) -- cgit v1.2.3