Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont add vector if already present in url. #43

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading