2023-04-22 18:55:47 +02:00
|
|
|
export default function isMastodonLinkMaybe(url) {
|
2023-12-03 13:40:00 +01:00
|
|
|
try {
|
2024-07-21 13:06:38 +02:00
|
|
|
const { pathname, hash, hostname } = URL.parse(url);
|
2023-12-03 13:40:00 +01:00
|
|
|
return (
|
|
|
|
/^\/.*\/\d+$/i.test(pathname) ||
|
2023-12-28 08:42:27 +01:00
|
|
|
/^\/(@[^/]+|users\/[^/]+)\/(statuses|posts)\/\w+\/?$/i.test(pathname) || // GoToSocial, Takahe
|
2023-12-03 13:40:00 +01:00
|
|
|
/^\/notes\/[a-z0-9]+$/i.test(pathname) || // Misskey, Firefish
|
|
|
|
/^\/(notice|objects)\/[a-z0-9-]+$/i.test(pathname) || // Pleroma
|
2024-06-08 15:36:09 +02:00
|
|
|
/^\/@[^/]+\/post\/[a-z0-9]+$/i.test(pathname) || // Threads
|
2024-07-05 10:19:04 +02:00
|
|
|
/^\/@[^/]+\/[a-z0-9]+[a-z0-9\-]+[a-z0-9]+$/i.test(pathname) || // Hollo
|
2024-07-21 13:06:38 +02:00
|
|
|
(hostname === 'fed.brid.gy' && pathname.startsWith('/r/http')) || // Bridgy Fed
|
2023-12-03 13:40:00 +01:00
|
|
|
/#\/[^\/]+\.[^\/]+\/s\/.+/i.test(hash) // Phanpy 🫣
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-04-22 18:55:47 +02:00
|
|
|
}
|