From 540676ac909fb98d5d6ec22084ffd3d86c449fc7 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 11 Jan 2022 11:14:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/utils/NetworkUtils.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt index ed86fd290..acdd3638d 100644 --- a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt +++ b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt @@ -149,11 +149,10 @@ object NetworkUtils { /** * 获取二级域名,供cookie保存和读取 - * - * http://1.2.3.4 => http://1.2.3.4 - * https://www.example.com => https://example.com - * http://www.biquge.com.cn => http://biquge.com.cn - * http://www.content.example.com => http://example.com + * http://1.2.3.4 => 1.2.3.4 + * https://www.example.com => example.com + * http://www.biquge.com.cn => biquge.com.cn + * http://www.content.example.com => example.com */ fun getSubDomain(url: String): String { val baseUrl = getBaseUrl(url) ?: return "" @@ -164,8 +163,7 @@ object NetworkUtils { //判断是否为ip if (isIPAddress(host)) return baseUrl //PublicSuffixDatabase处理域名 - val domain = PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) - if (domain == null) baseUrl else "${schema}://${domain}" + PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) ?: baseUrl }.getOrDefault( if (baseUrl.indexOf(".") == baseUrl.lastIndexOf(".")) { baseUrl.substring(baseUrl.lastIndexOf("/") + 1)