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

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

View file

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