Skip to content

Commit

Permalink
Merge pull request #4369 from vector-im/feature/fre/fix_permalink_han…
Browse files Browse the repository at this point in the history
…dling

Fix permalink handling
  • Loading branch information
Florian14 authored Nov 2, 2021
2 parents 0d6e8bd + 13dc0e0 commit 1971652
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/4369.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix handling of links coming from web instance reported as malformed by mistake
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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? {
Expand Down

0 comments on commit 1971652

Please sign in to comment.