Fix mobile link (#4805)

* Fix path of mobile link. Adding a trailing `/`

* Reduce brain pressure.
This commit is contained in:
Benoit Marty
2025-06-02 16:11:30 +02:00
committed by GitHub
parent e02053d85e
commit b398fb47d2
4 changed files with 10 additions and 10 deletions
@@ -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",