From cec88971b67f80cfc07443e61124fc1473c76f7d Mon Sep 17 00:00:00 2001 From: Cynthia Date: Mon, 5 Dec 2022 21:20:38 -0700 Subject: [PATCH] fedimbed: mastodon fallback try 4 --- src/modules/fedimbed.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 7c5a036..41ff1ad 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -118,7 +118,8 @@ async function processUrl(msg, url) { if (PATH_REGEX.pleroma2.test(urlObj.pathname)) { redirUrl = url.replace("notice", "api/v1/statuses"); } else if (PATH_REGEX.mastodon.test(urlObj.pathname)) { - redirUrl = url.replace(/^\/@(.+?)\/(\d+)\/?/, "/api/v1/statuses/$2"); + const postId = url.match(/^\/@(.+?)\/(\d+)\/?/)?.[2]; + redirUrl = urlObj.origin + "/api/v1/statuses/" + postId; } else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) { redirUrl = url.replace(/^\/(.+?)\/statuses/, "/api/v1/statuses"); } else {