Switched to UrlEncoder
This commit is contained in:
parent
637503a0b2
commit
bd3ee412fe
5 changed files with 24 additions and 33 deletions
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.8.0" />
|
||||
<option name="version" value="1.8.10" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,10 +1,9 @@
|
|||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("com.github.ben-manes.versions") version "0.45.0"
|
||||
id("com.github.ben-manes.versions") version "0.46.0"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.22.0"
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
|
@ -32,6 +31,7 @@ repositories {
|
|||
dependencies {
|
||||
implementation(platform(kotlin("bom")))
|
||||
|
||||
implementation("net.thauvin.erik:urlencoder:1.3.0")
|
||||
implementation("org.json:json:20220924")
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
|
@ -40,8 +40,9 @@ dependencies {
|
|||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(11))
|
||||
}
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
|
@ -66,10 +67,6 @@ tasks {
|
|||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
|
||||
}
|
||||
|
||||
withType<Test> {
|
||||
testLogging {
|
||||
exceptionFormat = TestExceptionFormat.FULL
|
||||
|
@ -77,14 +74,6 @@ tasks {
|
|||
}
|
||||
}
|
||||
|
||||
withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
|
||||
this.jvmTarget = java.targetCompatibility.toString()
|
||||
}
|
||||
|
||||
withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configureEach {
|
||||
this.jvmTarget = java.targetCompatibility.toString()
|
||||
}
|
||||
|
||||
withType<GenerateMavenPom> {
|
||||
destination = file("$projectDir/pom.xml")
|
||||
}
|
||||
|
@ -149,8 +138,8 @@ publishing {
|
|||
}
|
||||
}
|
||||
scm {
|
||||
connection.set("scm:git://github.com/$gitHub.git")
|
||||
developerConnection.set("scm:git@github.com:$gitHub.git")
|
||||
connection.set("scm:git:https://github.com/$gitHub.git")
|
||||
developerConnection.set("scm:git:git@github.com:$gitHub.git")
|
||||
url.set(mavenUrl)
|
||||
}
|
||||
issueManagement {
|
||||
|
|
14
pom.xml
14
pom.xml
|
@ -27,8 +27,8 @@
|
|||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git://github.com/ethauvin/jokeapi.git</connection>
|
||||
<developerConnection>scm:git@github.com:ethauvin/jokeapi.git</developerConnection>
|
||||
<connection>scm:git:https://github.com/ethauvin/jokeapi.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:ethauvin/jokeapi.git</developerConnection>
|
||||
<url>https://github.com/ethauvin/jokeapi</url>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
|
@ -40,7 +40,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-bom</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>1.8.10</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -50,9 +50,15 @@
|
|||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>1.8.10</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.thauvin.erik</groupId>
|
||||
<artifactId>urlencoder</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
|
|
|
@ -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