mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-22 17:31:55 +00:00
ui: additional check for plain domains (#7699)
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
1 parent
d673a6b021
commit
1bd7c95006
2 files changed
+4
-5
No files matched your search
+1
-1
@@ -632,7 +632,7 @@ private val nonAsciiChar = Regex("[^\\x00-\\x7F]")
|
||||
fun unicodeMarker(c: String): String = "[U+" + Integer.toHexString(c.codePointAt(0)).uppercase().padStart(4, '0') + "]"
|
||||
|
||||
fun displayedUri(uri: String): String {
|
||||
val authorityStart = uri.indexOf("://").takeIf { it >= 0 }?.plus(3) ?: uri.length
|
||||
val authorityStart = uri.indexOf("://").takeIf { it >= 0 }?.plus(3) ?: 0
|
||||
val authorityEnd = uri.indexOfAny(charArrayOf('/', '?', '#'), authorityStart).takeIf { it >= 0 } ?: uri.length
|
||||
val authority = uri.substring(authorityStart, authorityEnd).replace(nonAsciiChar) { unicodeMarker(it.value) }
|
||||
return uri.replaceRange(authorityStart, authorityEnd, authority).replace(invisibleChar) { unicodeMarker(it.value) }
|
||||
|
||||
Reference in new issue
Block a user