Skip to content

Commit

Permalink
Decode URL manually - otherwise encoded commas get double-encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
jvmusin committed Feb 28, 2024
1 parent 31b3590 commit ec0936a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.springframework.web.reactive.function.client.support.WebClientAdapter
import org.springframework.web.service.invoker.HttpServiceProxyFactory
import org.springframework.web.service.invoker.createClient
import org.springframework.web.util.UriComponentsBuilder
import java.net.URLDecoder

@Component
class SybonApiFactory(
Expand All @@ -17,7 +18,11 @@ class SybonApiFactory(
private inline fun <reified T : Any> createApi(): T {
val webClientBuilder = WebClient.builder()
.filter { request, next ->
val newUri = UriComponentsBuilder.fromUri(request.url()).queryParam("api_key", apiKey).build().toUri()
val initialUrl = URLDecoder.decode(request.url().toString(), Charsets.UTF_8)
val newUri = UriComponentsBuilder.fromUriString(initialUrl)
.queryParam("api_key", apiKey)
.build()
.toUri()
val newRequest = ClientRequest.from(request).url(newUri).build()
next.exchange(newRequest)
}.codecs {
Expand Down

0 comments on commit ec0936a

Please sign in to comment.