Skip to content

Commit d23c117

Browse files
committed
fix(android): preserve gateway i18n inventory
1 parent 062a9da commit d23c117

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,9 @@ internal fun parseGatewayEndpointResult(rawInput: String): GatewayEndpointParseR
162162
if (!tls && !isLocalCleartextGatewayHost(host)) {
163163
return GatewayEndpointParseResult(error = GatewayEndpointValidationError.INSECURE_REMOTE_URL)
164164
}
165-
if (uri.port != -1 && uri.port !in 1..65535) {
166-
return GatewayEndpointParseResult(error = GatewayEndpointValidationError.INVALID_URL)
167-
}
168165
val defaultPort = if (tls) 443 else 18789
169166
val displayPort = if (tls) 443 else 80
170-
val port = uri.port.takeIf { it in 1..65535 } ?: defaultPort
167+
val port = gatewayPort(uri.port, defaultPort) ?: return GatewayEndpointParseResult(error = GatewayEndpointValidationError.INVALID_URL)
171168
val displayHost = if (host.contains(":")) "[$host]" else host
172169
val displayUrl =
173170
if (port == displayPort && defaultPort == displayPort) {
@@ -247,6 +244,13 @@ internal fun gatewayEndpointValidationMessage(
247244
}
248245
}
249246

247+
private fun gatewayPort(port: Int, defaultPort: Int): Int? =
248+
when {
249+
port == -1 -> defaultPort
250+
port in 1..65535 -> port
251+
else -> null
252+
}
253+
250254
/** Builds a URL from manual host/port/tls fields for shared endpoint parsing. */
251255
internal fun composeGatewayManualUrl(
252256
hostInput: String,

0 commit comments

Comments
 (0)