Skip to content

Commit

Permalink
fix: remove extra encoding replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Dwairi committed Jan 14, 2025
1 parent d6feecd commit 1d26f86
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,12 @@ abstract class RequestBody {
val encodedForm =
formData
.map { (key, value) ->
"${encode(key, charset)}=${encode(value, charset)}"
"${URLEncoder.encode(key, charset.name())}=${URLEncoder.encode(value, charset.name())}"
}.joinToString("&")

val contentBytes = encodedForm.toByteArray(charset)

return create(contentBytes.inputStream(), CommonMediaTypes.APPLICATION_FORM_URLENCODED)
}

private fun encode(
value: String,
charset: Charset,
): String =
URLEncoder
.encode(value, charset.name())
.replace("+", "%20")
.replace("*", "%2A")
.replace("%7E", "~")
}
}

0 comments on commit 1d26f86

Please sign in to comment.