This commit is contained in:
gedoor 2022-01-11 12:11:21 +08:00
parent 540676ac90
commit a4c616ca24
2 changed files with 3 additions and 7 deletions

View File

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

View File

@ -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)
)
} }
/** /**