<commit_before>package jp.toastkid.yobidashi.libs.network

import android.webkit.CookieManager
import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.HttpUrl

/**
 * For sharing [WebView]'s cookie.
 *
 * @author toastkidjp
 */
object WebViewCookieHandler : CookieJar {

    private const val DELIMITER = ";"

    override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
        val urlString = url.toString() ?: return
        val cookieManager = CookieManager.getInstance()
        cookies.forEach { cookieManager.setCookie(urlString, it.toString()) }
    }

    override fun loadForRequest(url: HttpUrl): List<Cookie> {
        val urlString = url.toString() ?: return emptyList()
        val cookieManager = CookieManager.getInstance()
        val cookiesString = cookieManager.getCookie(urlString)

        return if (cookiesString != null && cookiesString.isNotEmpty()) {
            cookiesString
                    .split(DELIMITER)
                    .mapNotNull { Cookie.parse(url, it) }
        } else {
            emptyList()
        }
    }
}<commit_msg>refactor #244 Remove useless elvis operator.<commit_after>package jp.toastkid.yobidashi.libs.network

import android.webkit.CookieManager
import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.HttpUrl

/**
 * For sharing [WebView]'s cookie.
 *
 * @author toastkidjp
 */
object WebViewCookieHandler : CookieJar {

    private const val DELIMITER = ";"

    override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
        val urlString = url.toString()
        val cookieManager = CookieManager.getInstance()
        cookies.forEach { cookieManager.setCookie(urlString, it.toString()) }
    }

    override fun loadForRequest(url: HttpUrl): List<Cookie> {
        val urlString = url.toString()
        val cookieManager = CookieManager.getInstance()
        val cookiesString = cookieManager.getCookie(urlString)

        return if (cookiesString != null && cookiesString.isNotEmpty()) {
            cookiesString
                    .split(DELIMITER)
                    .mapNotNull { Cookie.parse(url, it) }
        } else {
            emptyList()
        }
    }
}
{'fraction_non_alphanumeric': 0.0993103448275862, 'fraction_numerical': 0.004137931034482759, 'mean_word_length': 2.7777777777777777, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '2772153', 'n_tokens_mistral': 628, 'n_tokens_neox': 594, 'n_words': 136}