mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Permalink: move method implementation from service to factory
This commit is contained in:
parent
744523b200
commit
afb49430be
2 changed files with 5 additions and 10 deletions
|
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.permalinks
|
|||
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
|
||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class DefaultPermalinkService @Inject constructor(
|
||||
|
@ -42,9 +41,6 @@ internal class DefaultPermalinkService @Inject constructor(
|
|||
}
|
||||
|
||||
override fun getLinkedId(url: String): String? {
|
||||
return url
|
||||
.takeIf { it.startsWith(MATRIX_TO_URL_BASE) }
|
||||
?.substring(MATRIX_TO_URL_BASE.length)
|
||||
?.substringBeforeLast("?")
|
||||
return permalinkFactory.getLinkedId(url)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,11 +60,10 @@ internal class PermalinkFactory @Inject constructor(
|
|||
}
|
||||
|
||||
fun getLinkedId(url: String): String? {
|
||||
val isSupported = url.startsWith(MATRIX_TO_URL_BASE)
|
||||
|
||||
return if (isSupported) {
|
||||
url.substring(MATRIX_TO_URL_BASE.length)
|
||||
} else null
|
||||
return url
|
||||
.takeIf { it.startsWith(MATRIX_TO_URL_BASE) }
|
||||
?.substring(MATRIX_TO_URL_BASE.length)
|
||||
?.substringBeforeLast("?")
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue