From 28fd9911b077efcfc7a9c966b12338dfee430adf Mon Sep 17 00:00:00 2001 From: Mike Barnes Date: Mon, 7 Aug 2023 19:39:54 +1000 Subject: [PATCH 1/3] Update LinkHelper.kt Add URL formats used by Bookwyrm --- app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt index 04176a11..72d0a09d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt @@ -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()) || From e290df5499ae4bf4722da17f85c7e4a1f978adf7 Mon Sep 17 00:00:00 2001 From: Mike Barnes Date: Mon, 7 Aug 2023 19:43:03 +1000 Subject: [PATCH 2/3] Update LinkHelperTest.kt Add test URLs for Bookwyrm --- .../test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt index 3b053d01..0d877e8b 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt @@ -367,7 +367,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) ) } } From 83de22950d9ce5fb45345e27a28f138201ff7f3c Mon Sep 17 00:00:00 2001 From: Mike Barnes Date: Tue, 8 Aug 2023 19:10:36 +1000 Subject: [PATCH 3/3] Update LinkHelperTest.kt Remove negative test for a URL that's invalid for Pleroma, but valid for Bookwyrm --- app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt index 0d877e8b..f0f879c3 100644 --- a/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/util/LinkHelperTest.kt @@ -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),