mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
PreviewUrl: protocol is mandatory (exclude rstp://)
This commit is contained in:
parent
fa7b0a24a7
commit
1161dcb299
1 changed files with 2 additions and 0 deletions
|
@ -25,6 +25,7 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class UrlsExtractor @Inject constructor() {
|
internal class UrlsExtractor @Inject constructor() {
|
||||||
|
// Sadly Patterns.WEB_URL_WITH_PROTOCOL is not public so filter the protocol later
|
||||||
private val urlRegex = Patterns.WEB_URL.toRegex()
|
private val urlRegex = Patterns.WEB_URL.toRegex()
|
||||||
|
|
||||||
fun extract(event: Event): List<String> {
|
fun extract(event: Event): List<String> {
|
||||||
|
@ -35,6 +36,7 @@ internal class UrlsExtractor @Inject constructor() {
|
||||||
?.body
|
?.body
|
||||||
?.let { urlRegex.findAll(it) }
|
?.let { urlRegex.findAll(it) }
|
||||||
?.map { it.value }
|
?.map { it.value }
|
||||||
|
?.filter { it.startsWith("https://") || it.startsWith("http://") }
|
||||||
?.distinct()
|
?.distinct()
|
||||||
?.toList()
|
?.toList()
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
|
|
Loading…
Reference in a new issue