-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a partial fix to #556, but it at least prevents crashing when an unknown URL type is encountered. There is still some work to do, since the markdown plugin doesn't properly interpret URLs the way we want. User-related parsing still doesn't work because there's work needed in the markdown layer, but once that's done, this should just work as intended.
- Loading branch information
1 parent
f680226
commit 8b75fd2
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package com.jerboa | |
import androidx.compose.ui.unit.dp | ||
import com.jerboa.datatypes.api.GetUnreadCountResponse | ||
import com.jerboa.ui.theme.SMALL_PADDING | ||
import com.jerboa.api.API | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
|
||
|
@@ -136,4 +137,19 @@ class UtilsKtTest { | |
assertEquals("1.2M", siFormat(1234500)) | ||
assertEquals("12M", siFormat(12345000)) | ||
} | ||
|
||
@Test | ||
fun testParseUrl() { | ||
val cases = mapOf( | ||
"https://feddit.de" to "https://feddit.de", | ||
"/c/community" to "https://${API.currentInstance}/c/community", | ||
"/c/[email protected]" to "https://instance.ml/c/community", | ||
"[email protected]" to "https://instance.ml/c/community", | ||
"!community" to "https://${API.currentInstance}/c/community", | ||
"/u/[email protected]" to "https://instance.ml/u/user", | ||
"@[email protected]" to "https://instance.ml/u/user", | ||
) | ||
|
||
cases.forEach { (url, exp) -> assertEquals(exp, parseUrl(url)) } | ||
} | ||
} |