Skip to content

Commit 550405e

Browse files
committed
Add encodeURLQueryComponent()
1 parent 2a1b759 commit 550405e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/kotlin/src/main/kotlin/com/xebia/functional/xef/auto/reasoning/WikipediaSearchByParamsExample.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ suspend fun main() {
1414
val answerByPageId = client.searchByPageId(searchDataByPageId)
1515

1616
val searchDataByTitle = WikipediaClient.SearchDataByParam(
17-
title = "Departments%20of%20Colombia"
17+
title = "Departments of Colombia"
1818
)
1919
val answerByTitle = client.searchByTitle(searchDataByTitle)
2020

reasoning/src/commonMain/kotlin/com/xebia/functional/xef/reasoning/wikipedia/WikipediaClient.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class WikipediaClient : AutoCloseable, AutoClose by autoClose() {
7777
}
7878

7979
suspend fun searchByTitle(searchData: SearchDataByParam): Page {
80-
return http.get("https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&redirects=1&titles=${searchData.title}") {
80+
return http.get("https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&redirects=1&titles=${searchData.title?.encodeURLQueryComponent()}") {
8181
contentType(ContentType.Application.Json)
8282
}.body<SearchByParamResult>().searchResults.pages.firstNotNullOf { it.value }
8383
}

0 commit comments

Comments
 (0)