aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
index 5ae6856b..093c8c94 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
@@ -18,6 +18,7 @@ package com.pitchedapps.frost.facebook
import android.net.Uri
import com.pitchedapps.frost.utils.L
+import com.pitchedapps.frost.utils.urlEncode
import java.net.URLDecoder
import java.nio.charset.StandardCharsets
@@ -89,21 +90,19 @@ class FbUrlFormatter(url: String) {
return cleanedUrl
}
- override fun toString(): String {
- val builder = StringBuilder()
- builder.append(cleaned)
+ override fun toString(): String = buildString {
+ append(cleaned)
if (queries.isNotEmpty()) {
- builder.append("?")
+ append("?")
queries.forEach { (k, v) ->
if (v.isEmpty()) {
- builder.append("$k&")
+ append("${k.urlEncode()}&")
} else {
- builder.append("$k=$v&")
+ append("${k.urlEncode()}=${v.urlEncode()}&")
}
}
}
- return builder.removeSuffix("&").toString()
- }
+ }.removeSuffix("&")
fun toLogList(): List<String> {
val list = mutableListOf(cleaned)