-
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
63623cc
commit fcb80a4
Showing
2 changed files
with
66 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.jerboa | ||
|
||
import com.jerboa.api.API | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.net.URL | ||
|
||
class UtilsKtTest { | ||
@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)) } | ||
} | ||
} |