@@ -29,7 +29,6 @@ import java.net.InetAddress
2929
3030import algolia .objects .RequestOptions
3131import io .netty .resolver .NameResolver
32- import io .lemonlabs .uri .dsl ._
3332import org .asynchttpclient .{Request , RequestBuilder }
3433
3534private [algolia] sealed trait HttpVerb
@@ -67,7 +66,7 @@ private[algolia] case class HttpPayload(
6766 headers : Map [String , String ],
6867 dnsNameResolver : NameResolver [InetAddress ]
6968 ): Request = {
70- val uri = path.foldLeft(host)((url, p) => url / p )
69+ val uri = path.foldLeft(host)((url, p) => insertPath( url, p) )
7170
7271 var builder : RequestBuilder =
7372 new RequestBuilder ().setMethod(verb.toString).setUrl(uri)
@@ -109,4 +108,17 @@ private[algolia] case class HttpPayload(
109108 s " $verb $host${_path}${_query}${_body}"
110109 }
111110
111+ private def insertPath (url : String , path : String ) =
112+ url.indexOf('?' ) match {
113+ case - 1 => appendPath(url, path)
114+ case i => appendPath(url.substring(0 , i), path) + url.substring(i)
115+ }
116+
117+ private def appendPath (url : String , path : String ) =
118+ if (url.endsWith(" /" )) {
119+ url + path
120+ } else {
121+ url + " /" + path
122+ }
123+
112124}
0 commit comments