Fix mobile link (#4805)
* Fix path of mobile link. Adding a trailing `/` * Reduce brain pressure.
This commit is contained in:
parent
9dbaa2ed40
commit
37344a4f7d
4 changed files with 10 additions and 10 deletions
|
|
@ -91,7 +91,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!--
|
<!--
|
||||||
Element mobile links
|
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">
|
<intent-filter android:autoVerify="true">
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
@ -102,7 +102,7 @@
|
||||||
<data android:scheme="https" />
|
<data android:scheme="https" />
|
||||||
<!-- Matching asset file: https://mobile.element.io/.well-known/assetlinks.json -->
|
<!-- Matching asset file: https://mobile.element.io/.well-known/assetlinks.json -->
|
||||||
<data android:host="mobile.element.io" />
|
<data android:host="mobile.element.io" />
|
||||||
<data android:path="/element" />
|
<data android:path="/element/" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!--
|
<!--
|
||||||
matrix.to links
|
matrix.to links
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class DefaultLoginIntentResolver @Inject constructor() : LoginIntentResolver {
|
||||||
override fun parse(uriString: String): LoginParams? {
|
override fun parse(uriString: String): LoginParams? {
|
||||||
val uri = uriString.toUri()
|
val uri = uriString.toUri()
|
||||||
if (uri.host != "mobile.element.io") return null
|
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 accountProvider = uri.getQueryParameter("account_provider") ?: return null
|
||||||
val loginHint = uri.getQueryParameter("login_hint")
|
val loginHint = uri.getQueryParameter("login_hint")
|
||||||
return LoginParams(
|
return LoginParams(
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class DefaultLoginIntentResolverTest {
|
||||||
@Test
|
@Test
|
||||||
fun `nominal case`() {
|
fun `nominal case`() {
|
||||||
val sut = DefaultLoginIntentResolver()
|
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(
|
assertThat(sut.parse(uriString)).isEqualTo(
|
||||||
LoginParams(
|
LoginParams(
|
||||||
accountProvider = "example.org",
|
accountProvider = "example.org",
|
||||||
|
|
@ -30,7 +30,7 @@ class DefaultLoginIntentResolverTest {
|
||||||
@Test
|
@Test
|
||||||
fun `extra unknown param`() {
|
fun `extra unknown param`() {
|
||||||
val sut = DefaultLoginIntentResolver()
|
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(
|
assertThat(sut.parse(uriString)).isEqualTo(
|
||||||
LoginParams(
|
LoginParams(
|
||||||
accountProvider = "example.org",
|
accountProvider = "example.org",
|
||||||
|
|
@ -42,7 +42,7 @@ class DefaultLoginIntentResolverTest {
|
||||||
@Test
|
@Test
|
||||||
fun `no account provider`() {
|
fun `no account provider`() {
|
||||||
val sut = DefaultLoginIntentResolver()
|
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()
|
assertThat(sut.parse(uriString)).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,14 +63,14 @@ class DefaultLoginIntentResolverTest {
|
||||||
@Test
|
@Test
|
||||||
fun `wrong host`() {
|
fun `wrong host`() {
|
||||||
val sut = DefaultLoginIntentResolver()
|
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()
|
assertThat(sut.parse(uriString)).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `no login_hint param`() {
|
fun `no login_hint param`() {
|
||||||
val sut = DefaultLoginIntentResolver()
|
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(
|
assertThat(sut.parse(uriString)).isEqualTo(
|
||||||
LoginParams(
|
LoginParams(
|
||||||
accountProvider = "example.org",
|
accountProvider = "example.org",
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# Please see LICENSE files in the repository root for full details.
|
# Please see LICENSE files in the repository root for full details.
|
||||||
|
|
||||||
# Format is:
|
# 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 \
|
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"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue