File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit/ui/settings/advanced Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ class RgsServerViewModel @Inject constructor(
9191 _uiState .update { it.copy(isLoading = true ) }
9292
9393 viewModelScope.launch(bgDispatcher) {
94- lightningRepo.restartWithRgsServer(url)
94+ lightningRepo.restartWithRgsServer(normalizeUrl( url) )
9595 .onSuccess {
9696 _uiState .update {
9797 val newState = it.copy(
@@ -128,15 +128,12 @@ class RgsServerViewModel @Inject constructor(
128128 )
129129 }
130130
131- private fun isValidURL (data : String ): Boolean {
132- val normalized = if (! data.startsWith(" http://" ) && ! data.startsWith(" https://" )) {
133- " https://$data "
134- } else {
135- data
136- }
131+ private fun normalizeUrl (url : String ): String =
132+ if (! url.startsWith(" http://" ) && ! url.startsWith(" https://" )) " https://$url " else url
137133
134+ private fun isValidURL (data : String ): Boolean {
138135 return runCatching {
139- val uri = URI (normalized )
136+ val uri = URI (normalizeUrl(data) )
140137 val hostname = uri.host ? : return false
141138
142139 if (Env .isDebug && hostname == " localhost" ) return true
You can’t perform that action at this time.
0 commit comments