branch: elpa/mastodon
commit 32d3c5667fe67a4c5bf0379a098c65d82f5e0c0c
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>

    more fedi-url-p work/tests
---
 lisp/mastodon.el       |  7 +++++--
 test/mastodon-tests.el | 21 +++++++++++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 0137993b35..ea461b4101 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -648,12 +648,15 @@ If FORCE, do a lookup regardless of the result of 
`mastodon--fedi-url-p'."
           (string-match "^/profile/[[:alpha:]_]+$" query)
           (string-match "^/p/[[:alpha:]_]+/[[:digit:]]+$" query)
           (string-match "^/[[:alpha:]_]+$" query) ;; ?
-          (string-match "^/u/[[:alpha:]_]+$" query)
+          (string-match "^/u/[[:alnum:]_]+$" query)
           ;; a lemmy post must NOT open in mastodon.el lest we get stuck in
           ;; a self-loading circle and can't load the URL in the lemmy
           ;; post itself:
           ;; (string-match "^/post/[[:digit:]]+$" query)
-          (string-match "^/comment/[[:digit:]]+$" query) ; lemmy
+          ;; FIXME: or perhaps we need to load lemmy posts in mastodon.el,
+          ;; but then force the self-link that they contain to load
+          ;; externally?
+          (string-match "^/comment/[[:digit:]]+$" query) ; lemmy comment
           (string-match "^/@[^/]+/posts/[[:alnum:]]+$" query) ;; akkoma post
           (string-match "^/@[^/]+/statuses/[[:alnum:]]" query) ; GTS status
           ;; (string-match "^/@[[:alpha:]-_]/" query) ;; flipboard post
diff --git a/test/mastodon-tests.el b/test/mastodon-tests.el
index 3d6dcca01a..d894aaab44 100644
--- a/test/mastodon-tests.el
+++ b/test/mastodon-tests.el
@@ -45,6 +45,14 @@
    ;; Lemmy comment:
    (not (mastodon--fedi-url-p
          "https://lemmy.ml/post/53786458/28261605";)))
+  (should
+   ;; lemmy comment 2:
+   (mastodon--fedi-url-p
+    "https://lemmy.ml/comment/28252098";))
+  (should
+   ;; Lemmy user:
+   (mastodon--fedi-url-p
+    "https://lemmy.ml/u/Trying2KnowMyself";))
   (should
    ;; Misskey post:
    (mastodon--fedi-url-p
@@ -66,5 +74,14 @@
    (mastodon--fedi-url-p
     "https://todon.nl/collections/116879312823651190";))
   ;; TODO: Fed.brid.gy:
-  
-  )
+
+  ;; Non-fedi links
+  (should
+   (not (mastodon--fedi-url-p
+         "https://x.com/asdf/status/3412352456345";)))
+  (should
+   (not (mastodon--fedi-url-p
+         "https://example.com";)))
+  (should
+   (not (mastodon--fedi-url-p
+         "https://www.theguardian.com/profile/kitty-sayers";))))

Reply via email to