From 0effa7a880c40f31067b888ab801f6e702360863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Dumas?= Date: Tue, 11 Jun 2024 08:36:46 +0200 Subject: [PATCH] Dont add vector if already present in url. (#43) This PR prevent vector to be added twice if already present in the URL. Fix issue #42 --- buildSrc/src/main/kotlin/Config.kt | 2 +- .../integrationlayer/utils/VectorInterceptor.kt | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/Config.kt b/buildSrc/src/main/kotlin/Config.kt index d5ba0ea..ca6aa36 100644 --- a/buildSrc/src/main/kotlin/Config.kt +++ b/buildSrc/src/main/kotlin/Config.kt @@ -5,7 +5,7 @@ object Config { const val major = 0 const val minor = 10 - const val patch = 0 + const val patch = 1 const val versionName = "$major.$minor.$patch" const val maven_group = "ch.srg.data.provider" diff --git a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/utils/VectorInterceptor.kt b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/utils/VectorInterceptor.kt index 2d53bd8..d9d46b0 100644 --- a/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/utils/VectorInterceptor.kt +++ b/dataprovider-retrofit/src/main/java/ch/srg/dataProvider/integrationlayer/utils/VectorInterceptor.kt @@ -13,14 +13,19 @@ import okhttp3.Response class VectorInterceptor(private val vector: String) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { - val original = chain.request() - val originalHttpUrl = original.url + val originalRequest = chain.request() + val originalHttpUrl = originalRequest.url + + if (originalHttpUrl.queryParameter("vector") != null) { + return chain.proceed(originalRequest) + } + val url = originalHttpUrl.newBuilder() .addQueryParameter("vector", vector) .build() // Request customization: add request headers - val requestBuilder = original.newBuilder() + val requestBuilder = originalRequest.newBuilder() .url(url) val request = requestBuilder.build() return chain.proceed(request)