tylerwilson
11/08/2019, 3:42 PMParameters.apply { append(key, value) }
issue is that it is encoding spaces as ‘+’, whereas I need then as ‘%20’. Anybody know if there is a way to adjust this? Or perhaps (like Retrofit) there could be an ‘appendEncoded()’ type call? Thank you!tylerwilson
11/08/2019, 3:55 PMfun List<Pair<String, String?>>.formUrlEncodeTo(out: Appendable) {
joinTo(
out, "&"
) {
val key = it.first.encodeURLParameter(spaceToPlus = true)
if (it.second == null) {
key
}
else {
val value = it.second.toString().encodeURLParameter(spaceToPlus = true)
"$key=$value"
}
}
}
Seems kind of rude to assume we want spaces as pluses. The encodeURLParameter even defaults to false, but this code is overriding that.