phanpy/src/utils/isMastodonLinkMaybe.jsx

12 lines
493 B
React
Raw Normal View History

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