File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
main/kotlin/at/bitfire/davdroid/ui/setup
test/kotlin/at/bitfire/davdroid/network Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import dagger.assisted.AssistedFactory
1616import dagger.assisted.AssistedInject
1717import dagger.hilt.android.lifecycle.HiltViewModel
1818import dagger.hilt.android.qualifiers.ApplicationContext
19+ import io.ktor.http.URLParserException
1920import io.ktor.http.Url
2021import kotlinx.coroutines.launch
2122import java.util.logging.Level
@@ -55,9 +56,13 @@ class NextcloudLoginModel @AssistedInject constructor(
5556 baseUrl
5657 else
5758 " https://$baseUrl "
58- val baseKtorUrl = Url (baseUrlWithPrefix)
59+ val baseKtorUrl = try {
60+ Url (baseUrlWithPrefix)
61+ } catch (_: URLParserException ) {
62+ null
63+ }
5964
60- val canContinue = ! inProgress
65+ val canContinue = ! inProgress && baseKtorUrl != null
6166 }
6267
6368 var uiState by mutableStateOf(UiState ())
@@ -102,7 +107,7 @@ class NextcloudLoginModel @AssistedInject constructor(
102107 */
103108 fun startLoginFlow () {
104109 val baseUrl = uiState.baseKtorUrl
105- if (uiState.inProgress)
110+ if (uiState.inProgress || baseUrl == null )
106111 return
107112
108113 uiState = uiState.copy(
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class NextcloudLoginFlowTest {
1717 fun `loginFlowUrl accepts v2 URL` () {
1818 assertEquals(
1919 Url (" http://example.com/index.php/login/v2" ),
20- flow.loginFlowUrl(Url (" http://example.com/index.php/login/flow " ))
20+ flow.loginFlowUrl(Url (" http://example.com/index.php/login/v2 " ))
2121 )
2222 }
2323
You can’t perform that action at this time.
0 commit comments