2023-04-22 19:55:47 +03:00
|
|
|
export default function isMastodonLinkMaybe(url) {
|
2023-12-03 15:40:00 +03:00
|
|
|
try {
|
2024-06-14 03:34:50 +03:00
|
|
|
const { pathname, hash } = URL.parse(url);
|
2023-12-03 15:40:00 +03:00
|
|
|
return (
|
|
|
|
/^\/.*\/\d+$/i.test(pathname) ||
|
2023-12-28 10:42:27 +03:00
|
|
|
/^\/(@[^/]+|users\/[^/]+)\/(statuses|posts)\/\w+\/?$/i.test(pathname) || // GoToSocial, Takahe
|
2023-12-03 15:40:00 +03:00
|
|
|
/^\/notes\/[a-z0-9]+$/i.test(pathname) || // Misskey, Firefish
|
|
|
|
/^\/(notice|objects)\/[a-z0-9-]+$/i.test(pathname) || // Pleroma
|
2024-06-08 16:36:09 +03:00
|
|
|
/^\/@[^/]+\/post\/[a-z0-9]+$/i.test(pathname) || // Threads
|
2023-12-03 15:40:00 +03:00
|
|
|
/#\/[^\/]+\.[^\/]+\/s\/.+/i.test(hash) // Phanpy 🫣
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-04-22 19:55:47 +03:00
|
|
|
}
|