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) {