Fixed URL encoding

This commit is contained in:
Erik C. Thauvin 2022-09-26 22:36:02 -07:00
parent acf56b2178
commit 2f7b98c064
4 changed files with 9 additions and 6 deletions

View file

@ -65,7 +65,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.5' implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.5'
// Logging // Logging
implementation 'org.slf4j:slf4j-api:2.0.1' implementation 'org.slf4j:slf4j-api:2.0.2'
implementation "org.apache.logging.log4j:log4j-api:$versions.log4j" implementation "org.apache.logging.log4j:log4j-api:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-core:$versions.log4j" implementation "org.apache.logging.log4j:log4j-core:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-slf4j2-impl:$versions.log4j" implementation "org.apache.logging.log4j:log4j-slf4j2-impl:$versions.log4j"
@ -74,7 +74,7 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.10.0' implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'net.aksingh:owm-japis:2.5.3.0' implementation 'net.aksingh:owm-japis:2.5.3.0'
implementation 'net.objecthunter:exp4j:0.4.8' implementation 'net.objecthunter:exp4j:0.4.8'
implementation 'org.json:json:20220320' implementation 'org.json:json:20220924'
implementation 'org.jsoup:jsoup:1.15.3' implementation 'org.jsoup:jsoup:1.15.3'
implementation 'org.twitter4j:twitter4j-core:4.0.7' implementation 'org.twitter4j:twitter4j-core:4.0.7'

View file

@ -141,6 +141,9 @@ object Utils {
*/ */
@JvmStatic @JvmStatic
fun String.encodeUrl(): String = URLEncoder.encode(this, StandardCharsets.UTF_8) fun String.encodeUrl(): String = URLEncoder.encode(this, StandardCharsets.UTF_8)
.replace("+", "%20")
.replace("*", "%2A")
.replace("%7E", "~")
/** /**
* Returns a property as an int. * Returns a property as an int.

View file

@ -144,7 +144,7 @@ class UtilsTest {
@Test @Test
fun testEncodeUrl() { fun testEncodeUrl() {
assertThat("Hello Günter".encodeUrl()).isEqualTo("Hello+G%C3%BCnter") assertThat("Hello Günter".encodeUrl()).isEqualTo("Hello%20G%C3%BCnter")
} }
@Test @Test

View file

@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle #Generated by the Semver Plugin for Gradle
#Sat Sep 24 10:52:55 PDT 2022 #Sat Sep 24 22:15:01 PDT 2022
version.buildmeta=676 version.buildmeta=677
version.major=0 version.major=0
version.minor=8 version.minor=8
version.patch=0 version.patch=0
version.prerelease=rc version.prerelease=rc
version.project=mobibot version.project=mobibot
version.semver=0.8.0-rc+676 version.semver=0.8.0-rc+677