Skip to content

Commit 9e57545

Browse files
author
code3-dev
committed
Add Search
1 parent 22e1091 commit 9e57545

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/src/main/java/com/pira/ccloud/data/repository/SearchRepository.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import okhttp3.Request
1212
import org.json.JSONArray
1313
import org.json.JSONObject
1414
import java.net.URLEncoder
15+
import java.nio.charset.StandardCharsets
1516
import java.util.concurrent.TimeUnit
1617

1718
class SearchRepository {
@@ -26,7 +27,8 @@ class SearchRepository {
2627
suspend fun search(query: String): SearchResult {
2728
return withContext(Dispatchers.IO) {
2829
try {
29-
val encodedQuery = URLEncoder.encode(query, "UTF-8")
30+
// Properly encode the query for URL paths
31+
val encodedQuery = URLEncoder.encode(query, StandardCharsets.UTF_8.toString()).replace("+", "%20")
3032
val url = "$BASE_URL/$encodedQuery/$API_KEY/"
3133
val request = Request.Builder()
3234
.url(url)

0 commit comments

Comments
 (0)