Add new mastodon status url format to looksLikeMastodonUrl. (#3136)

Fixes #3092
This commit is contained in:
Levi Bard 2023-01-09 21:07:22 +01:00 committed by GitHub
parent ca01776847
commit 8ca92d9fde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -276,6 +276,7 @@ private fun openLinkInCustomTab(uri: Uri, context: Context) {
// https://mastodon.foo.bar/@User
// https://mastodon.foo.bar/@User/43456787654678
// https://mastodon.foo.bar/users/User/statuses/43456787654678
// https://pleroma.foo.bar/users/User
// https://pleroma.foo.bar/users/9qTHT2ANWUdXzENqC0
// https://pleroma.foo.bar/notice/9sBHWIlwwGZi5QGlHc
@ -306,6 +307,7 @@ fun looksLikeMastodonUrl(urlString: String): Boolean {
return uri.path.let {
it.matches("^/@[^/]+$".toRegex()) ||
it.matches("^/@[^/]+/\\d+$".toRegex()) ||
it.matches("^/users/[^/]+/statuses/\\d+$".toRegex()) ||
it.matches("^/users/\\w+$".toRegex()) ||
it.matches("^/notice/[a-zA-Z0-9]+$".toRegex()) ||
it.matches("^/objects/[-a-f0-9]+$".toRegex()) ||

View file

@ -321,6 +321,7 @@ class LinkHelperTest {
arrayOf("http://mastodon.foo.bar/@abc123", true),
arrayOf("https://mastodon.foo.bar/@user/345667890345678", true),
arrayOf("https://mastodon.foo.bar/@user/3", true),
arrayOf("https://mastodon.foo.bar/users/User/statuses/43456787654678", true),
arrayOf("https://pleroma.foo.bar/users/meh3223", true),
arrayOf("https://pleroma.foo.bar/users/meh3223_bruh", true),
arrayOf("https://pleroma.foo.bar/users/2345", true),