https://kotlinlang.org logo
#ktor
Title
# ktor
a

Alexander

08/16/2019, 1:02 PM
Hi there. Trying to build url with path containing special symbols:
Copy code
URLBuilder(host = "localhost").apply {
    path("%?")
    parameters["?"] = "?"
}
    .buildString()
    .also(::println)
The above code produces
<http://localhost/%25??%3F=%3F>
url. The question mark in the path is not encoded. I whould expect the following:
<http://localhost/%25%3F?%3F=%3F>
. If I encode it explicitly
path("%?".encodeURLPath())
the percent sign is encoded twice.
URLBuilder
uses
encodeURLQueryComponent
to encode a path: https://github.com/ktorio/ktor/blob/1.2.3/ktor-http/common/src/io/ktor/http/URLBuilder.kt#L50 Possibly it should use
encodeURLPath
?
2 Views