Fix mobile link (#4805)
* Fix path of mobile link. Adding a trailing `/` * Reduce brain pressure.
This commit is contained in:
@@ -91,7 +91,7 @@
|
||||
</intent-filter>
|
||||
<!--
|
||||
Element mobile links
|
||||
Example: https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org
|
||||
Example: https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org
|
||||
-->
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
@@ -102,7 +102,7 @@
|
||||
<data android:scheme="https" />
|
||||
<!-- Matching asset file: https://mobile.element.io/.well-known/assetlinks.json -->
|
||||
<data android:host="mobile.element.io" />
|
||||
<data android:path="/element" />
|
||||
<data android:path="/element/" />
|
||||
</intent-filter>
|
||||
<!--
|
||||
matrix.to links
|
||||
|
||||
@@ -19,7 +19,7 @@ class DefaultLoginIntentResolver @Inject constructor() : LoginIntentResolver {
|
||||
override fun parse(uriString: String): LoginParams? {
|
||||
val uri = uriString.toUri()
|
||||
if (uri.host != "mobile.element.io") return null
|
||||
if (uri.path?.startsWith("/element")?.not() == true) return null
|
||||
if (uri.path.orEmpty().startsWith("/element").not()) return null
|
||||
val accountProvider = uri.getQueryParameter("account_provider") ?: return null
|
||||
val loginHint = uri.getQueryParameter("login_hint")
|
||||
return LoginParams(
|
||||
|
||||
@@ -18,7 +18,7 @@ class DefaultLoginIntentResolverTest {
|
||||
@Test
|
||||
fun `nominal case`() {
|
||||
val sut = DefaultLoginIntentResolver()
|
||||
val uriString = "https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org"
|
||||
val uriString = "https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org"
|
||||
assertThat(sut.parse(uriString)).isEqualTo(
|
||||
LoginParams(
|
||||
accountProvider = "example.org",
|
||||
@@ -30,7 +30,7 @@ class DefaultLoginIntentResolverTest {
|
||||
@Test
|
||||
fun `extra unknown param`() {
|
||||
val sut = DefaultLoginIntentResolver()
|
||||
val uriString = "https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org&extra=uknown"
|
||||
val uriString = "https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org&extra=uknown"
|
||||
assertThat(sut.parse(uriString)).isEqualTo(
|
||||
LoginParams(
|
||||
accountProvider = "example.org",
|
||||
@@ -42,7 +42,7 @@ class DefaultLoginIntentResolverTest {
|
||||
@Test
|
||||
fun `no account provider`() {
|
||||
val sut = DefaultLoginIntentResolver()
|
||||
val uriString = "https://mobile.element.io/element?login_hint=mxid:@alice:example.org"
|
||||
val uriString = "https://mobile.element.io/element/?login_hint=mxid:@alice:example.org"
|
||||
assertThat(sut.parse(uriString)).isNull()
|
||||
}
|
||||
|
||||
@@ -63,14 +63,14 @@ class DefaultLoginIntentResolverTest {
|
||||
@Test
|
||||
fun `wrong host`() {
|
||||
val sut = DefaultLoginIntentResolver()
|
||||
val uriString = "https://wrong.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org"
|
||||
val uriString = "https://wrong.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org"
|
||||
assertThat(sut.parse(uriString)).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `no login_hint param`() {
|
||||
val sut = DefaultLoginIntentResolver()
|
||||
val uriString = "https://mobile.element.io/element?account_provider=example.org"
|
||||
val uriString = "https://mobile.element.io/element/?account_provider=example.org"
|
||||
assertThat(sut.parse(uriString)).isEqualTo(
|
||||
LoginParams(
|
||||
accountProvider = "example.org",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# Please see LICENSE files in the repository root for full details.
|
||||
|
||||
# Format is:
|
||||
# https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org
|
||||
# https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org
|
||||
|
||||
adb shell am start -a android.intent.action.VIEW \
|
||||
-d "https://mobile.element.io/element?account_provider=element.io\\&login_hint=mxid:@alice:element.io"
|
||||
-d "https://mobile.element.io/element/?account_provider=element.io\\&login_hint=mxid:@alice:element.io"
|
||||
|
||||
Reference in New Issue
Block a user