Skip to content

Commit 4e6a6c3

Browse files
Robclaude
andcommitted
fix(outbound): URL-encode token in glucodroid.cloud URL; show subdomain before token
- Uri.encode() the ingest token so characters like +, &, =, # in base64-style tokens don't produce malformed query strings. - Move the subdomain field above the token field in the UI so the order matches the URL shape (subdomain → token) and users fill in the account identifier first. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8f7915c commit 4e6a6c3

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

Common/src/main/java/tk/glucodata/OutboundApiSettings.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tk.glucodata
22

33
import android.content.Context
4+
import android.net.Uri
45
import androidx.annotation.Keep
56
import org.json.JSONArray
67
import org.json.JSONObject
@@ -124,7 +125,7 @@ object OutboundApiSettings {
124125
if (normalizedPreset() == PRESET_GLUCODROID_CLOUD) {
125126
val subdomain = url.trim()
126127
if (subdomain.isBlank()) return ""
127-
return "https://$subdomain.glucodroid.cloud/api/v1/ingest?token=${token.trim()}"
128+
return "https://$subdomain.glucodroid.cloud/api/v1/ingest?token=${Uri.encode(token.trim())}"
128129
}
129130
val trimmed = url.trim()
130131
val replacementToken = if (normalizedPreset() == PRESET_TELEGRAM_BOT) {

Common/src/mobile/java/tk/glucodata/ui/OutboundApiSettingsScreen.kt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,20 @@ private fun DestinationEditor(
446446
onChangePreset = { showPresetSheet = true }
447447
)
448448

449+
if (isGlucodroid) {
450+
OutlinedTextField(
451+
value = destination.url,
452+
onValueChange = { onChange(destination.copy(url = it.trim())) },
453+
modifier = Modifier.fillMaxWidth(),
454+
singleLine = true,
455+
label = { Text(stringResource(R.string.outbound_api_glucodroid_subdomain)) },
456+
suffix = { Text(".glucodroid.cloud", color = MaterialTheme.colorScheme.onSurfaceVariant) },
457+
keyboardOptions = KeyboardOptions(
458+
keyboardType = KeyboardType.Text,
459+
imeAction = ImeAction.Next
460+
)
461+
)
462+
}
449463
if (isTelegram || isVk || isGlucodroid) {
450464
OutlinedTextField(
451465
value = destination.token,
@@ -504,20 +518,7 @@ private fun DestinationEditor(
504518
)
505519
}
506520

507-
if (isGlucodroid) {
508-
OutlinedTextField(
509-
value = destination.url,
510-
onValueChange = { onChange(destination.copy(url = it.trim())) },
511-
modifier = Modifier.fillMaxWidth(),
512-
singleLine = true,
513-
label = { Text(stringResource(R.string.outbound_api_glucodroid_subdomain)) },
514-
suffix = { Text(".glucodroid.cloud", color = MaterialTheme.colorScheme.onSurfaceVariant) },
515-
keyboardOptions = KeyboardOptions(
516-
keyboardType = KeyboardType.Text,
517-
imeAction = ImeAction.Next
518-
)
519-
)
520-
} else {
521+
if (!isGlucodroid) {
521522
OutlinedTextField(
522523
value = destination.url.ifBlank { OutboundApiSettings.defaultUrl(preset) },
523524
onValueChange = { onChange(destination.copy(url = it)) },

0 commit comments

Comments
 (0)