Compare commits

..

2 Commits

Author SHA1 Message Date
2dust
f610e1d20a Merge pull request #1879 from MUedsa/idn_to_accii
only domain idn to ascii
2022-12-30 18:16:37 +08:00
MUEDSA
9f4127a588 only domain idn to ascii 2022-12-30 17:08:36 +08:00

View File

@@ -431,19 +431,9 @@ object Utils {
}
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
}
val url = URL(str)
return URL(url.protocol, IDN.toASCII(url.host, IDN.ALLOW_UNASSIGNED), url.port, url.file)
.toExternalForm()
}
}