fix(android): use scheme default port for gateway setup URLs (#43540)

* fix(android): use scheme default port for gateway setup URLs

* test(android): cover gateway endpoint default ports

* fix(android): preserve direct gateway default port

* fix(android): preserve explicit cleartext port display

* fix: preserve Android gateway setup URL ports (#43540) (thanks @fmercurio)

---------

Co-authored-by: clawdia <clawdia@fmercurio.tech>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
This commit is contained in:
Felippe Mercurio
2026-03-22 01:51:38 -03:00
committed by GitHub
parent 0f6dbb4390
commit 8790c54635
3 changed files with 98 additions and 2 deletions

View File

@@ -97,8 +97,25 @@ internal fun parseGatewayEndpoint(rawInput: String): GatewayEndpointConfig? {
"wss", "https" -> true
else -> true
}
val port = uri.port.takeIf { it in 1..65535 } ?: if (tls) 443 else 18789
val displayUrl = "${if (tls) "https" else "http"}://$host:$port"
val defaultPort =
when (scheme) {
"wss", "https" -> 443
"ws", "http" -> 18789
else -> 443
}
val displayPort =
when (scheme) {
"wss", "https" -> 443
"ws", "http" -> 80
else -> 443
}
val port = uri.port.takeIf { it in 1..65535 } ?: defaultPort
val displayUrl =
if (port == displayPort && defaultPort == displayPort) {
"${if (tls) "https" else "http"}://$host"
} else {
"${if (tls) "https" else "http"}://$host:$port"
}
return GatewayEndpointConfig(host = host, port = port, tls = tls, displayUrl = displayUrl)
}