mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
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:
parent
7f90dda96f
commit
985dbfe97d
@ -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 == '/' }
|
||||
}
|
||||
|
@ -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://"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user