phanpy/src/utils/isMastodonLinkMaybe.jsx

12 lines
492 B
React
Raw Normal View History

2023-04-22 18:55:47 +02:00
export default function isMastodonLinkMaybe(url) {
const { pathname, hash } = new URL(url);
2023-04-25 05:16:00 +02:00
return (
2023-06-13 15:08:59 +02:00
/^\/.*\/\d+$/i.test(pathname) ||
2023-09-28 05:19:24 +02:00
/^\/@[^/]+\/(statuses|posts)\/\w+\/?$/i.test(pathname) || // GoToSocial, Takahe
2023-06-27 06:19:55 +02:00
/^\/notes\/[a-z0-9]+$/i.test(pathname) || // Misskey, Calckey
/^\/notes\/[a-z0-9]+$/i.test(pathname) || // Misskey, Calckey
/^\/(notice|objects)\/[a-z0-9-]+$/i.test(pathname) || // Pleroma
/#\/[^\/]+\.[^\/]+\/s\/.+/i.test(hash) // Phanpy 🫣
2023-04-25 05:16:00 +02:00
);
2023-04-22 18:55:47 +02:00
}