phanpy/src/utils/isMastodonLinkMaybe.jsx

12 lines
493 B
React
Raw Normal View History

2023-04-22 19:55:47 +03:00
export default function isMastodonLinkMaybe(url) {
const { pathname, hash } = new URL(url);
2023-04-25 06:16:00 +03:00
return (
2023-06-13 16:08:59 +03:00
/^\/.*\/\d+$/i.test(pathname) ||
2023-09-28 06:19:24 +03:00
/^\/@[^/]+\/(statuses|posts)\/\w+\/?$/i.test(pathname) || // GoToSocial, Takahe
2023-11-25 16:22:51 +03:00
/^\/notes\/[a-z0-9]+$/i.test(pathname) || // Misskey, Firefish
/^\/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 06:16:00 +03:00
);
2023-04-22 19:55:47 +03:00
}