ktorio / ktor

Framework for quickly creating connected applications in Kotlin with minimal effort
https://ktor.io
Apache License 2.0
12.82k stars 1.04k forks source link

URLBuilder: extra '/' at the end, when parameters are used #958

Closed talanov closed 5 years ago

talanov commented 5 years ago

Ktor Version:

1.1.2

Ktor Engine Used(client or server and name):

Multiplatform/client (io.ktor:ktor-client-core, io.ktor:ktor-client-core-jvm)

JVM Version, Operating System and Relevant Context:

Tested on Android 8.1.0

Feedback

Code sample

url {
                    protocol = URLProtocol.HTTPS
                    host = endpoint.url // String: "url.com"
                    parameters.append(name = "before", value = endpoint.parameters.get("before"))
                    parameters.append(name = "limit", value = (endpoint.parameters.get("limit") as? Int).toString()
                }
                println(url.buildString().toString())
}

Prints:

https://url.com/?before=now&limit=50

Expected:

https://url.com?before=now&limit=50

talanov commented 5 years ago

Also if I'm trying to do this:

url("https://url.com?before=now&limit=50"), I'm getting Fail to parse url: https://url.com?before=now&limit=50