fedimbed: try 5
This commit is contained in:
parent
10943008aa
commit
8a070bb4b2
1 changed files with 3 additions and 2 deletions
|
@ -11,7 +11,7 @@ const FRIENDLY_USERAGENT =
|
|||
const URLS_REGEX = /(?:\s|^)(https?:\/\/[^\s<]+[^<.,:;"'\]\s])/g;
|
||||
|
||||
const PATH_REGEX = {
|
||||
mastodon: /^\/@(.+?)\/\d+\/?/,
|
||||
mastodon: /^\/@(.+?)\/(\d+)\/?/,
|
||||
mastodon2: /^\/(.+?)\/statuses\/\d+\/?/,
|
||||
pleroma:
|
||||
/^\/objects\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/?/,
|
||||
|
@ -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 = urlObj.pathname.match(PATH_REGEX.mastodon)?.[2];
|
||||
redirUrl = urlObj.origin + "/api/v1/statuses/" + postId;
|
||||
} else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) {
|
||||
redirUrl = url.replace(/^\/(.+?)\/statuses/, "/api/v1/statuses");
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue