aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-12-18 11:16:30 +0100
committeradamw <adam@warski.org>2017-12-18 11:16:30 +0100
commit2b1ed89d7468234c738f9f9789be23030bc6bdbc (patch)
tree7d1c9a7b3f25cbce00ce0f24acabc5734c018751 /core
parent1bdfd6f9de694760eeb6165889a61a4e893e52ff (diff)
downloadsttp-2b1ed89d7468234c738f9f9789be23030bc6bdbc.tar.gz
sttp-2b1ed89d7468234c738f9f9789be23030bc6bdbc.tar.bz2
sttp-2b1ed89d7468234c738f9f9789be23030bc6bdbc.zip
Support both arrays and interables in the uri interpolator
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala4
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala4
2 files changed, 6 insertions, 2 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala
index f77951c..8d0024a 100644
--- a/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala
+++ b/core/src/main/scala/com/softwaremill/sttp/UriInterpolator.scala
@@ -501,7 +501,9 @@ object UriInterpolator {
valueTs match {
case Vector() => acc // tailTs must be empty then as well
- case Vector(ExpressionToken(s: Seq[_])) =>
+ case Vector(ExpressionToken(s: Iterable[_])) =>
+ doToSeq(tailTs, acc ++ s.flatMap(anyToStringOpt).toVector)
+ case Vector(ExpressionToken(s: Array[_])) =>
doToSeq(tailTs, acc ++ s.flatMap(anyToStringOpt).toVector)
case _ =>
val values = valueTs
diff --git a/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala
index f8d32ed..e417233 100644
--- a/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala
@@ -81,7 +81,9 @@ class UriInterpolatorTests extends FunSuite with Matchers {
(uri"http://example.com/$v1/p/$v4",
s"http://example.com/$v1/p/$v4encoded"),
(uri"http://example.com/a/${List(v2, "c", v4)}/b",
- s"http://example.com/a/$v2encoded/c/$v4encoded/b")
+ s"http://example.com/a/$v2encoded/c/$v4encoded/b"),
+ (uri"http://example.com/${"a/b/c".split('/')}",
+ s"http://example.com/a/b/c")
),
"path with parameters" -> List(
(uri"http://example.com/$v1?x=$v2",