From 057a2d2f841a9f923ee5458793f661506a9bf604 Mon Sep 17 00:00:00 2001 From: Ulf Rompe Date: Wed, 6 Aug 2025 17:59:35 +0200 Subject: [PATCH] Detect Pleroma and Pixelfed profile links - Re-introduce the server blacklist unchanged - Incorporate it into the Fediverse profile regex These two platforms sadly have a non-unique URL scheme, so it may be better to keep the blacklist in place to filter out all the github and codeberg URLs. --- src/Mastodon.ts | 4 +++- src/test.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mastodon.ts b/src/Mastodon.ts index 39b57e4..0f907d6 100644 --- a/src/Mastodon.ts +++ b/src/Mastodon.ts @@ -186,10 +186,12 @@ ${text.split("\n").map(txt => " > " + txt).join("\n")}`) return overview.length + rest.join("\n").length + 1 } + private static notMastodon = ["wiki.openstreetmap.org", "hdyc.neis-one.org", "matrix.to","facebook.com","github", "tasks.hotosm.org","community.openstreetmap.org","mapillary.com","wikimedia.org","wikipedia.org","wikidata.org"] // Fediverse profiles look like this: // Mastodon, Akkoma, etc.: https://foo.bar/@user // Friendica: https://foo.bar/profile/user - private static isProbablyMastodon = new RegExp("^https?://[^/]+/(profile/|@)[^/]+/?$") + // Pixelfed, Pleroma: https://foo.bar/user + private static isProbablyMastodon = new RegExp(`^https?://(?!.*(?:${MastodonPoster.notMastodon.join('|')}))[a-zA-Z0-9.-]+/(profile/|@?)[a-zA-Z0-9_.-]+/?$`) static isProbablyMastodonLink(link: string) { return this.isProbablyMastodon.test(link) diff --git a/src/test.ts b/src/test.ts index 0a6d1d6..8e83057 100644 --- a/src/test.ts +++ b/src/test.ts @@ -9,6 +9,7 @@ const uids = [ 8404193, // queerthoughts 153277, // rompe 393359, // hector + 14124839, // ilja has a Pleroma link ] for (const uid of uids) {