confirming to reviewed PR

This commit is contained in:
cfriedlander 2021-07-28 18:55:10 +02:00
parent 618ab6c862
commit f45338be4c
2 changed files with 7 additions and 4 deletions

1
changelog.d/3735.bugfix Normal file
View file

@ -0,0 +1 @@
the element-based domain permalinks (e.g. https://app.element.io/#/user/@chagai95:matrix.org) don't have the mxid in the first param (like matrix.to does - https://matrix.to/#/@chagai95:matrix.org) but rather in the second after /user/ so /user/mxid

View file

@ -21,12 +21,14 @@ import android.net.UrlQuerySanitizer
import org.matrix.android.sdk.api.MatrixPatterns
/**
* This class turns an uri to a [PermalinkData]
* This class turns a uri to a [PermalinkData]
* element-based domains (e.g. https://app.element.io/#/user/@chagai95:matrix.org) permalinks or matrix.to permalinks (e.g. https://matrix.to/#/@chagai95:matrix.org)
*
*/
object PermalinkParser {
/**
* Turns an uri string to a [PermalinkData]
* Turns a uri string to a [PermalinkData]
*/
fun parse(uriString: String): PermalinkData {
val uri = Uri.parse(uriString)
@ -34,7 +36,7 @@ object PermalinkParser {
}
/**
* Turns an uri to a [PermalinkData]
* Turns a uri to a [PermalinkData]
*/
fun parse(uri: Uri): PermalinkData {
if (!uri.toString().startsWith(PermalinkService.MATRIX_TO_URL_BASE)) {
@ -53,7 +55,7 @@ object PermalinkParser {
.filter { it.isNotEmpty() }
.take(2)
// the base domain permalinks don't have the mxid in the first param but in the second after /user/mxid
// the the element-based domain permalinks (e.g. https://app.element.io/#/user/@chagai95:matrix.org) don't have the mxid in the first param (like matrix.to does - https://matrix.to/#/@chagai95:matrix.org) but rather in the second after /user/ so /user/mxid
var identifier = params.getOrNull(0);
if (identifier.equals("user")) {
identifier = params.getOrNull(1)