Skip to content

Commit

Permalink
Merge pull request #1879 from MUedsa/idn_to_accii
Browse files Browse the repository at this point in the history
only domain idn to ascii
  • Loading branch information
2dust committed Dec 30, 2022
2 parents a211bc2 + 9f4127a commit f610e1d
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit f610e1d

Please sign in to comment.