fedimbed: copypaste moment

This commit is contained in:
Cynthia Foxwell 2022-12-05 21:21:50 -07:00
parent cec88971b6
commit 2a624d23ea

View file

@ -118,8 +118,7 @@ async function processUrl(msg, url) {
if (PATH_REGEX.pleroma2.test(urlObj.pathname)) { if (PATH_REGEX.pleroma2.test(urlObj.pathname)) {
redirUrl = url.replace("notice", "api/v1/statuses"); redirUrl = url.replace("notice", "api/v1/statuses");
} else if (PATH_REGEX.mastodon.test(urlObj.pathname)) { } else if (PATH_REGEX.mastodon.test(urlObj.pathname)) {
const postId = url.match(/^\/@(.+?)\/(\d+)\/?/)?.[2]; redirUrl = url.replace(/^\/@(.+?)\/(\d+)\/?/, "/api/v1/statuses/$2");
redirUrl = urlObj.origin + "/api/v1/statuses/" + postId;
} else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) { } else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) {
redirUrl = url.replace(/^\/(.+?)\/statuses/, "/api/v1/statuses"); redirUrl = url.replace(/^\/(.+?)\/statuses/, "/api/v1/statuses");
} else { } else {
@ -131,7 +130,7 @@ async function processUrl(msg, url) {
if (redirUrl) { if (redirUrl) {
const rawPostData2 = await fetch( const rawPostData2 = await fetch(
url.replace("notice", "api/v1/statuses"), redirUrl,
{ {
headers: { headers: {
"User-Agent": FRIENDLY_USERAGENT, "User-Agent": FRIENDLY_USERAGENT,