<commit_before>package com.commit451.gitlab.api

import com.commit451.gitlab.model.Account
import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException

/**
 * Adds the private token to all requests
 */
class AuthenticationRequestInterceptor(private val account: Account) : Interceptor {

    companion object {
        const val PRIVATE_TOKEN_HEADER_FIELD = "Private-Token"
        private const val PRIVATE_TOKEN_GET_PARAMETER = "private_token"
    }

    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        var request = chain.request()

        var url = request.url()
        val serverUrl = account.serverUrl ?: "https://example.com"

        if (isSameServer(url.toString(), serverUrl)) {
            val privateToken = account.privateToken
            privateToken?.let {
                url = url.newBuilder()
                        .addQueryParameter(PRIVATE_TOKEN_GET_PARAMETER, it)
                        .build()

                request = request.newBuilder()
                        .header(PRIVATE_TOKEN_HEADER_FIELD, it)
                        .url(url)
                        .build()<commit_msg>Drop the redundant private_token GET parameter<commit_after>package com.commit451.gitlab.api

import com.commit451.gitlab.model.Account
import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException

/**
 * Adds the private token to all requests
 */
class AuthenticationRequestInterceptor(private val account: Account) : Interceptor {

    companion object {
        const val PRIVATE_TOKEN_HEADER_FIELD = "Private-Token"
        private const val PRIVATE_TOKEN_GET_PARAMETER = "private_token"
    }

    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        var request = chain.request()

        var url = request.url()
        val serverUrl = account.serverUrl ?: "https://example.com"

        if (isSameServer(url.toString(), serverUrl)) {
            val privateToken = account.privateToken
            privateToken?.let {
                request = request.newBuilder()
                        .header(PRIVATE_TOKEN_HEADER_FIELD, it)
                        .url(url)
                        .build()
{'fraction_non_alphanumeric': 0.08570159857904085, 'fraction_numerical': 0.007104795737122558, 'mean_word_length': 2.3930722891566263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6022061', 'n_tokens_mistral': 604, 'n_tokens_neox': 582, 'n_words': 135}