Convert idn domain
This commit is contained in:
@@ -488,7 +488,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
||||
if (!it.second.enabled) {
|
||||
return@forEach
|
||||
}
|
||||
val url = it.second.url
|
||||
val url = Utils.idnToASCII(it.second.url)
|
||||
if (!Utils.isValidUrl(url)) {
|
||||
return@forEach
|
||||
}
|
||||
|
||||
@@ -429,5 +429,21 @@ object Utils {
|
||||
fun removeWhiteSpace(str: String?): String? {
|
||||
return str?.replace(" ", "")
|
||||
}
|
||||
|
||||
fun idnToASCII(str: String): String {
|
||||
var url = str
|
||||
var prot = ""
|
||||
if (url.startsWith(AppConfig.HTTPS_PROTOCOL)) {
|
||||
url = url.substring(8)
|
||||
prot = AppConfig.HTTPS_PROTOCOL
|
||||
} else if (url.startsWith(AppConfig.HTTP_PROTOCOL)) {
|
||||
url = url.substring(7)
|
||||
prot = AppConfig.HTTP_PROTOCOL
|
||||
}
|
||||
url = prot + IDN.toASCII(url, IDN.ALLOW_UNASSIGNED)
|
||||
if (url != str) return url else {
|
||||
return str
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user