pull/1515/head
gedoor 3 years ago
parent 540676ac90
commit a4c616ca24
  1. 1
      app/src/main/assets/updateLog.md
  2. 9
      app/src/main/java/io/legado/app/utils/NetworkUtils.kt

@ -14,6 +14,7 @@
**2022/01/11** **2022/01/11**
* 紧急修复在线tts朗读bug * 紧急修复在线tts朗读bug
* 紧急修复登录问题
**2022/01/10** **2022/01/10**

@ -155,20 +155,15 @@ object NetworkUtils {
* http://www.content.example.com => example.com * http://www.content.example.com => example.com
*/ */
fun getSubDomain(url: String): String { fun getSubDomain(url: String): String {
val baseUrl = getBaseUrl(url) ?: return "" val baseUrl = getBaseUrl(url) ?: return url
return kotlin.runCatching { return kotlin.runCatching {
val mURL = URL(baseUrl) val mURL = URL(baseUrl)
val schema: String = mURL.protocol
val host: String = mURL.host val host: String = mURL.host
//判断是否为ip //判断是否为ip
if (isIPAddress(host)) return baseUrl if (isIPAddress(host)) return baseUrl
//PublicSuffixDatabase处理域名 //PublicSuffixDatabase处理域名
PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) ?: baseUrl PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) ?: baseUrl
}.getOrDefault( }.getOrDefault(url)
if (baseUrl.indexOf(".") == baseUrl.lastIndexOf(".")) {
baseUrl.substring(baseUrl.lastIndexOf("/") + 1)
} else baseUrl.substring(baseUrl.indexOf(".") + 1)
)
} }
/** /**

Loading…
Cancel
Save