Commit fba75958 authored by Ricki Hirner's avatar Ricki Hirner 🐑

Login with URL: assume https:// URI scheme if none given

parent 3ed16ae5
Pipeline #94890028 passed with stages
in 8 minutes and 54 seconds
......@@ -67,10 +67,16 @@ class DefaultLoginCredentialsFragment: Fragment() {
fun validateUrl() {
model.baseUrlError.value = null
try {
val uri = URI(model.baseUrl.value.orEmpty())
val originalUrl = model.baseUrl.value.orEmpty()
val uri = URI(originalUrl)
if (uri.scheme.equals("http", true) || uri.scheme.equals("https", true)) {
// http:// or https:// scheme → OK
valid = true
loginModel.baseURI = uri
} else if (uri.scheme == null) {
// empty URL scheme, assume https://
model.baseUrl.value = "https://$originalUrl"
validateUrl()
} else
model.baseUrlError.value = getString(R.string.login_url_must_be_http_or_https)
} catch (e: Exception) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment