mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-15 15:02:49 +01:00
refactor: Make sure to remove trim '/'
The host url for syncyomi have to be http://[ip]:[port] or https://[url] if there is trailing whitespace or '/' It will error since the api will be called like this https://example//api/download which then return html instead of json since it tries to go to the page instead of hitting the api.
This commit is contained in:
parent
25285e7b66
commit
383bfc5dde
@ -434,11 +434,21 @@ fun PurgeConfirmationDialog(
|
||||
|
||||
@Composable
|
||||
private fun getSelfHostPreferences(syncPreferences: SyncPreferences): List<Preference> {
|
||||
val scope = rememberCoroutineScope()
|
||||
return listOf(
|
||||
Preference.PreferenceItem.EditTextPreference(
|
||||
title = stringResource(R.string.pref_sync_host),
|
||||
subtitle = stringResource(R.string.pref_sync_host_summ),
|
||||
pref = syncPreferences.syncHost(),
|
||||
onValueChanged = { newValue ->
|
||||
scope.launch {
|
||||
// Trim spaces at the beginning and end, then remove trailing slash if present
|
||||
val trimmedValue = newValue.trim()
|
||||
val modifiedValue = trimmedValue.trimEnd { it == '/' }
|
||||
syncPreferences.syncHost().set(modifiedValue)
|
||||
}
|
||||
true
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.EditTextPreference(
|
||||
title = stringResource(R.string.pref_sync_api_key),
|
||||
|
Loading…
Reference in New Issue
Block a user