From 618ab6c8624b5532af541f7fc9403171a8a1af2a Mon Sep 17 00:00:00 2001 From: cfriedlander Date: Mon, 26 Jul 2021 14:25:31 +0200 Subject: [PATCH 1/3] the base domain permalinks don't have the mxid in the first param but in the second after /user/mxid --- .../android/sdk/api/session/permalinks/PermalinkParser.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt index 347a3bb5313..e433f2a1085 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt @@ -53,7 +53,12 @@ object PermalinkParser { .filter { it.isNotEmpty() } .take(2) - val identifier = params.getOrNull(0) + // the base domain permalinks don't have the mxid in the first param but in the second after /user/mxid + var identifier = params.getOrNull(0); + if (identifier.equals("user")) { + identifier = params.getOrNull(1) + } + val extraParameter = params.getOrNull(1) return when { identifier.isNullOrEmpty() -> PermalinkData.FallbackLink(uri) From f45338be4c2235d1094ca766c837f292540fdd1a Mon Sep 17 00:00:00 2001 From: cfriedlander Date: Wed, 28 Jul 2021 18:55:10 +0200 Subject: [PATCH 2/3] confirming to reviewed PR --- changelog.d/3735.bugfix | 1 + .../sdk/api/session/permalinks/PermalinkParser.kt | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelog.d/3735.bugfix diff --git a/changelog.d/3735.bugfix b/changelog.d/3735.bugfix new file mode 100644 index 00000000000..8262af627b5 --- /dev/null +++ b/changelog.d/3735.bugfix @@ -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 \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt index e433f2a1085..164a48a45b4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt @@ -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) From 426389194e32844df22876838776a29db1d74d4e Mon Sep 17 00:00:00 2001 From: chagai95 <31655082+chagai95@users.noreply.github.com> Date: Thu, 29 Jul 2021 13:35:03 +0200 Subject: [PATCH 3/3] removing double the --- .../android/sdk/api/session/permalinks/PermalinkParser.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt index 164a48a45b4..b25ec86402c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt @@ -55,7 +55,7 @@ object PermalinkParser { .filter { it.isNotEmpty() } .take(2) - // 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 + // 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)