|
|
@ -155,7 +155,8 @@ object NetworkUtils { |
|
|
|
* http://www.biquge.com.cn => http://biquge.com.cn |
|
|
|
* http://www.biquge.com.cn => http://biquge.com.cn |
|
|
|
* http://www.content.example.com => http://example.com |
|
|
|
* http://www.content.example.com => http://example.com |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun getSubDomain(url: String?): String { |
|
|
|
fun getSubDomain(url: String): String { |
|
|
|
|
|
|
|
return kotlin.runCatching { |
|
|
|
val baseUrl = getBaseUrl(url) ?: return "" |
|
|
|
val baseUrl = getBaseUrl(url) ?: return "" |
|
|
|
val mURL = URL(baseUrl) |
|
|
|
val mURL = URL(baseUrl) |
|
|
|
val schema: String = mURL.protocol |
|
|
|
val schema: String = mURL.protocol |
|
|
@ -164,7 +165,8 @@ object NetworkUtils { |
|
|
|
if (isIPAddress(host)) return baseUrl |
|
|
|
if (isIPAddress(host)) return baseUrl |
|
|
|
//PublicSuffixDatabase处理域名 |
|
|
|
//PublicSuffixDatabase处理域名 |
|
|
|
val domain = PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) |
|
|
|
val domain = PublicSuffixDatabase.get().getEffectiveTldPlusOne(host) |
|
|
|
return if (domain == null) baseUrl else "${schema}://${domain}" |
|
|
|
if (domain == null) baseUrl else "${schema}://${domain}" |
|
|
|
|
|
|
|
}.getOrDefault(url) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|