@@ -49,6 +49,7 @@ import io.reactivex.disposables.CompositeDisposable
4949import io.reactivex.disposables.Disposable
5050import io.reactivex.schedulers.Schedulers
5151import javax.inject.Inject
52+ import androidx.core.net.toUri
5253
5354@AutoInjector(NextcloudTalkApplication ::class )
5455class MainActivity :
@@ -386,7 +387,7 @@ class MainActivity :
386387 * 3. Current active user as fallback (if server matches)
387388 */
388389 private fun resolveTargetUser (users : List <User >, deepLinkResult : DeepLinkHandler .DeepLinkResult ): User ? {
389- val deepLinkHost = Uri .parse( deepLinkResult.serverUrl).host?.lowercase()
390+ val deepLinkHost = deepLinkResult.serverUrl.toUri( ).host?.lowercase()
390391 if (deepLinkHost.isNullOrBlank()) {
391392 return currentUserProviderOld.currentUser.blockingGet()
392393 }
@@ -395,21 +396,21 @@ class MainActivity :
395396 val username = deepLinkResult.username
396397 val exactMatch = if (username != null ) {
397398 users.find { user ->
398- val userHost = user.baseUrl?.let { Uri .parse(it ).host?.lowercase() }
399+ val userHost = user.baseUrl?.let { it.toUri( ).host?.lowercase() }
399400 userHost == deepLinkHost && user.username?.lowercase() == username.lowercase()
400401 }
401402 } else {
402403 null
403404 }
404405
405406 val serverMatch = users.find { user ->
406- val userHost = user.baseUrl?.let { Uri .parse(it ).host?.lowercase() }
407+ val userHost = user.baseUrl?.let { it.toUri( ).host?.lowercase() }
407408 userHost == deepLinkHost
408409 }
409410
410411 val currentUser = currentUserProviderOld.currentUser.blockingGet()
411412 val currentUserMatch = currentUser?.takeIf {
412- it.baseUrl?.let { url -> Uri .parse(url ).host?.lowercase() } == deepLinkHost
413+ it.baseUrl?.let { url -> url.toUri( ).host?.lowercase() } == deepLinkHost
413414 }
414415
415416 return exactMatch ? : serverMatch ? : currentUserMatch
0 commit comments