keeping the http:// schema in the server selection input field

- helps to highlight a non secture connection, for https we strip the prefix
This commit is contained in:
Adam Brown 2022-03-31 13:01:04 +01:00
parent 7f90dda96f
commit 985dbfe97d
2 changed files with 6 additions and 3 deletions

View File

@ -19,8 +19,8 @@ package im.vector.app.core.extensions
/**
* Ex: "https://matrix.org/" -> "matrix.org"
*/
fun String?.toReducedUrl(): String {
fun String?.toReducedUrl(keepSchema: Boolean = false): String {
return (this ?: "")
.substringAfter("://")
.run { if (keepSchema) this else substringAfter("://") }
.trim { it == '/' }
}

View File

@ -49,6 +49,9 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractSS
}
override fun updateWithState(state: OnboardingViewState) {
views.chooseServerInput.editText().setText(state.serverSelectionState.userUrlInput.toReducedUrl())
val userUrlInput = state.serverSelectionState.userUrlInput?.toReducedUrlKeepingSchemaIfInsecure()
views.chooseServerInput.editText().setText(userUrlInput)
}
private fun String.toReducedUrlKeepingSchemaIfInsecure() = toReducedUrl(keepSchema = this.startsWith("http://"))
}