Merge pull request #4369 from vector-im/feature/fre/fix_permalink_handling

Fix permalink handling
This commit is contained in:
Florian Renaud 2021-11-02 09:36:00 +01:00 committed by GitHub
commit 1971652ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

1
changelog.d/4369.bugfix Normal file
View File

@ -0,0 +1 @@
Fix handling of links coming from web instance reported as malformed by mistake

View File

@ -273,14 +273,13 @@ class HomeActivity :
val resolvedLink = when {
// Element custom scheme is not handled by the sdk, convert it to matrix.to link for compatibility
deepLink.startsWith(MATRIX_TO_CUSTOM_SCHEME_URL_BASE) -> {
val let = when {
when {
deepLink.startsWith(USER_LINK_PREFIX) -> deepLink.substring(USER_LINK_PREFIX.length)
deepLink.startsWith(ROOM_LINK_PREFIX) -> deepLink.substring(ROOM_LINK_PREFIX.length)
else -> null
}?.let { permalinkId ->
activeSessionHolder.getSafeActiveSession()?.permalinkService()?.createPermalink(permalinkId)
}
let
}
else -> deepLink
}

View File

@ -18,6 +18,7 @@ package im.vector.app.features.permalink
import android.content.Context
import android.net.Uri
import androidx.core.net.toUri
import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.extensions.isIgnored
@ -118,9 +119,8 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti
private fun isPermalinkSupported(context: Context, url: String): Boolean {
return url.startsWith(PermalinkService.MATRIX_TO_URL_BASE) ||
context.resources.getStringArray(R.array.permalink_supported_hosts).any {
url.startsWith(it)
}
context.resources.getStringArray(R.array.permalink_supported_hosts)
.any { url.toUri().host == it }
}
private suspend fun PermalinkData.RoomLink.getRoomId(): String? {