fedimbed: fix mastodon fallback try 3

This commit is contained in:
Cynthia Foxwell 2022-12-05 21:16:37 -07:00
parent 643cfa4501
commit 65efa56ee1

View file

@ -97,7 +97,9 @@ async function processUrl(msg, url) {
if (!postData) {
// We failed to get post.
// If we're fetching from Pleroma, assume it was due to AFM and use MastoAPI
// Assume it was due to AFM and use MastoAPI
// Follow redirect from /object since we need the ID from /notice
if (PATH_REGEX.pleroma.test(urlObj.pathname)) {
url = await fetch(url, {
method: "HEAD",
@ -116,7 +118,9 @@ 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(/@(.+?)\//, "api/v1/statuses/");
redirUrl = url.replace(/^\/@(.+?)\/(\d+)\/?/, "/api/v1/statuses/$2");
} else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) {
redirUrl = url.replace(/^\/(.+?)\/statuses/, "/api/v1/statuses");
} else {
logger.error(
"fedimbed",