Detect Bookwyrm URL formats (#3936)

While helping test an issue with
[Bookwyrm](https://github.com/bookwyrm-social/bookwyrm) I noticed that
the URL formats used by that project aren't checked as possible profile
or post links. They're quite close to a couple of others, so I just
copied close examples and edited a couple of terms.

It's pretty minor, I just used a previous commit as a reference. Let me
know if it needs anything more though. I've only quickly tested it on a
local build with a couple of links against a live Bookwyrm and it picks
them up as expected now.
This commit is contained in:
Levi Bard 2023-09-05 09:33:51 +02:00 committed by GitHub
commit 02404564e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -284,6 +284,8 @@ fun openLinkInCustomTab(uri: Uri, context: Context) {
// https://gts.foo.bar/@goblin/statuses/01GH9XANCJ0TA8Y95VE9H3Y0Q2
// https://gts.foo.bar/@goblin
// https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5
// https://bookwyrm.foo.bar/user/User
// https://bookwyrm.foo.bar/user/User/comment/123456
fun looksLikeMastodonUrl(urlString: String): Boolean {
val uri: URI
try {
@ -304,6 +306,8 @@ fun looksLikeMastodonUrl(urlString: String): Boolean {
it.matches("^/@[^/]+/\\d+$".toRegex()) ||
it.matches("^/users/[^/]+/statuses/\\d+$".toRegex()) ||
it.matches("^/users/\\w+$".toRegex()) ||
it.matches("^/user/[^/]+/comment/\\d+$".toRegex()) ||
it.matches("^/user/\\w+$".toRegex()) ||
it.matches("^/notice/[a-zA-Z0-9]+$".toRegex()) ||
it.matches("^/objects/[-a-f0-9]+$".toRegex()) ||
it.matches("^/notes/[a-z0-9]+$".toRegex()) ||

View File

@ -348,7 +348,6 @@ class LinkHelperTest {
arrayOf("https://pleroma.foo.bar/users/", false),
arrayOf("https://pleroma.foo.bar/users/meow/", false),
arrayOf("https://pleroma.foo.bar/users/@meow", false),
arrayOf("https://pleroma.foo.bar/user/2345", false),
arrayOf("https://pleroma.foo.bar/notices/123456", false),
arrayOf("https://pleroma.foo.bar/notice/@neverhappen/", false),
arrayOf("https://pleroma.foo.bar/object/abcdef-123-abcd-9876543", false),
@ -367,7 +366,9 @@ class LinkHelperTest {
arrayOf("https://pixelfed.social/connyduck", true),
arrayOf("https://gts.foo.bar/@goblin/statuses/01GH9XANCJ0TA8Y95VE9H3Y0Q2", true),
arrayOf("https://gts.foo.bar/@goblin", true),
arrayOf("https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5", true)
arrayOf("https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5", true),
arrayOf("https://bookwyrm.foo.bar/user/User", true),
arrayOf("https://bookwyrm.foo.bar/user/User/comment/123456", true)
)
}
}