Skip to content

Commit b398fb4

Browse files
authored
Fix mobile link (#4805)
* Fix path of mobile link. Adding a trailing `/` * Reduce brain pressure.
1 parent e02053d commit b398fb4

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</intent-filter>
9292
<!--
9393
Element mobile links
94-
Example: https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org
94+
Example: https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org
9595
-->
9696
<intent-filter android:autoVerify="true">
9797
<action android:name="android.intent.action.VIEW" />
@@ -102,7 +102,7 @@
102102
<data android:scheme="https" />
103103
<!-- Matching asset file: https://mobile.element.io/.well-known/assetlinks.json -->
104104
<data android:host="mobile.element.io" />
105-
<data android:path="/element" />
105+
<data android:path="/element/" />
106106
</intent-filter>
107107
<!--
108108
matrix.to links

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/DefaultLoginIntentResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DefaultLoginIntentResolver @Inject constructor() : LoginIntentResolver {
1919
override fun parse(uriString: String): LoginParams? {
2020
val uri = uriString.toUri()
2121
if (uri.host != "mobile.element.io") return null
22-
if (uri.path?.startsWith("/element")?.not() == true) return null
22+
if (uri.path.orEmpty().startsWith("/element").not()) return null
2323
val accountProvider = uri.getQueryParameter("account_provider") ?: return null
2424
val loginHint = uri.getQueryParameter("login_hint")
2525
return LoginParams(

features/login/impl/src/test/kotlin/io/element/android/features/login/impl/DefaultLoginIntentResolverTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DefaultLoginIntentResolverTest {
1818
@Test
1919
fun `nominal case`() {
2020
val sut = DefaultLoginIntentResolver()
21-
val uriString = "https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org"
21+
val uriString = "https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org"
2222
assertThat(sut.parse(uriString)).isEqualTo(
2323
LoginParams(
2424
accountProvider = "example.org",
@@ -30,7 +30,7 @@ class DefaultLoginIntentResolverTest {
3030
@Test
3131
fun `extra unknown param`() {
3232
val sut = DefaultLoginIntentResolver()
33-
val uriString = "https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org&extra=uknown"
33+
val uriString = "https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org&extra=uknown"
3434
assertThat(sut.parse(uriString)).isEqualTo(
3535
LoginParams(
3636
accountProvider = "example.org",
@@ -42,7 +42,7 @@ class DefaultLoginIntentResolverTest {
4242
@Test
4343
fun `no account provider`() {
4444
val sut = DefaultLoginIntentResolver()
45-
val uriString = "https://mobile.element.io/element?login_hint=mxid:@alice:example.org"
45+
val uriString = "https://mobile.element.io/element/?login_hint=mxid:@alice:example.org"
4646
assertThat(sut.parse(uriString)).isNull()
4747
}
4848

@@ -63,14 +63,14 @@ class DefaultLoginIntentResolverTest {
6363
@Test
6464
fun `wrong host`() {
6565
val sut = DefaultLoginIntentResolver()
66-
val uriString = "https://wrong.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org"
66+
val uriString = "https://wrong.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org"
6767
assertThat(sut.parse(uriString)).isNull()
6868
}
6969

7070
@Test
7171
fun `no login_hint param`() {
7272
val sut = DefaultLoginIntentResolver()
73-
val uriString = "https://mobile.element.io/element?account_provider=example.org"
73+
val uriString = "https://mobile.element.io/element/?account_provider=example.org"
7474
assertThat(sut.parse(uriString)).isEqualTo(
7575
LoginParams(
7676
accountProvider = "example.org",

tools/adb/deeplink_mobile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Please see LICENSE files in the repository root for full details.
77

88
# Format is:
9-
# https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org
9+
# https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org
1010

1111
adb shell am start -a android.intent.action.VIEW \
12-
-d "https://mobile.element.io/element?account_provider=element.io\\&login_hint=mxid:@alice:element.io"
12+
-d "https://mobile.element.io/element/?account_provider=element.io\\&login_hint=mxid:@alice:element.io"

0 commit comments

Comments
 (0)