Switched to UrlEncoder
This commit is contained in:
parent
637503a0b2
commit
bd3ee412fe
5 changed files with 24 additions and 33 deletions
|
@ -41,9 +41,8 @@ import net.thauvin.erik.jokeapi.models.Joke
|
|||
import net.thauvin.erik.jokeapi.models.Language
|
||||
import net.thauvin.erik.jokeapi.models.Parameter
|
||||
import net.thauvin.erik.jokeapi.models.Type
|
||||
import net.thauvin.erik.urlencoder.UrlEncoder
|
||||
import org.json.JSONObject
|
||||
import java.net.URLEncoder
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.logging.Logger
|
||||
import java.util.stream.Collectors
|
||||
|
||||
|
@ -86,10 +85,7 @@ object JokeApi {
|
|||
val param = it.next()
|
||||
urlBuilder.append(param.key)
|
||||
if (param.value.isNotEmpty()) {
|
||||
urlBuilder.append("=").append(
|
||||
URLEncoder.encode(param.value, StandardCharsets.UTF_8).replace("+", "%20")
|
||||
.replace("*", "%2A").replace("%7E", "~")
|
||||
)
|
||||
urlBuilder.append("=").append(UrlEncoder.encode(param.value))
|
||||
}
|
||||
if (it.hasNext()) {
|
||||
urlBuilder.append("&")
|
||||
|
|
|
@ -74,8 +74,8 @@ class JokeConfig private constructor(
|
|||
var idRange: IdRange = IdRange(),
|
||||
var amount: Int = 1,
|
||||
var safe: Boolean = false,
|
||||
var auth: String = "",
|
||||
var splitNewLine: Boolean = false
|
||||
var splitNewLine: Boolean = false,
|
||||
var auth: String = ""
|
||||
) {
|
||||
fun categories(categories: Set<Category>) = apply { this.categories = categories }
|
||||
fun lang(language: Language) = apply { lang = language }
|
||||
|
@ -86,8 +86,8 @@ class JokeConfig private constructor(
|
|||
fun idRange(idRange: IdRange) = apply { this.idRange = idRange }
|
||||
fun amount(amount: Int) = apply { this.amount = amount }
|
||||
fun safe(safe: Boolean) = apply { this.safe = safe }
|
||||
fun auth(auth: String) = apply { this.auth = auth }
|
||||
fun splitNewLine(splitNewLine: Boolean) = apply { this.splitNewLine = splitNewLine }
|
||||
fun auth(auth: String) = apply { this.auth = auth }
|
||||
|
||||
fun build() = JokeConfig(
|
||||
categories, lang, blacklistFlags, type, format, contains, idRange, amount, safe, splitNewLine, auth
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue