Skip to content

Commit 97ad0b7

Browse files
ly85206559cursoragentsteipete
authored
fix(android): bracket IPv6 hosts in manual gateway URL composition (#99107)
* fix(android): bracket IPv6 hosts in manual gateway URL composition Reuse formatGatewayAuthority when building manual gateway URLs so IPv6 loopback and LAN hosts parse correctly during onboarding connect setup. Co-authored-by: Cursor <[email protected]> * test(android): cover bracketed IPv6 gateway hosts * fix(android): avoid gateway i18n inventory churn --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
1 parent 36361fc commit 97ad0b7

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayConfigResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ internal fun composeGatewayManualUrl(
261261
}
262262
if (port !in 1..65535) return null
263263
val scheme = if (tls) "https" else "http"
264-
return "$scheme://$host:$port"
264+
return "$scheme://${ai.openclaw.app.gateway.formatGatewayAuthority(host, port)}"
265265
}
266266

267267
private fun parseJsonObject(input: String): JsonObject? = runCatching { gatewaySetupJson.parseToJsonElement(input).jsonObject }.getOrNull()

apps/android/app/src/test/java/ai/openclaw/app/ui/GatewayConfigResolverTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,24 @@ class GatewayConfigResolverTest {
606606
assertNull(url)
607607
}
608608

609+
@Test
610+
fun composeGatewayManualUrl_bracketsIpv6ForEndpointParsing() {
611+
for (hostInput in listOf("::1", "[::1]")) {
612+
val url = composeGatewayManualUrl(hostInput, "18789", tls = false)
613+
614+
assertEquals("http://[::1]:18789", url)
615+
assertEquals(
616+
GatewayEndpointConfig(
617+
host = "::1",
618+
port = 18789,
619+
tls = false,
620+
displayUrl = "http://[::1]:18789",
621+
),
622+
parseGatewayEndpoint(url!!),
623+
)
624+
}
625+
}
626+
609627
@Test
610628
fun resolveGatewayConnectConfigManualAcceptsTailscaleHostWithoutPort() {
611629
val resolved =

0 commit comments

Comments
 (0)