Fixed URL encoding
This commit is contained in:
parent
acf56b2178
commit
2f7b98c064
4 changed files with 9 additions and 6 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue