phanpy/src/utils/isMastodonLinkMaybe.jsx

10 lines
359 B
React
Raw Normal View History

2023-04-22 18:55:47 +02:00
export default function isMastodonLinkMaybe(url) {
2023-05-05 02:54:06 +02:00
const { pathname } = 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
/^\/(notice|objects)\/[a-z0-9-]+$/i.test(pathname) // Pleroma
2023-04-25 05:16:00 +02:00
);
2023-04-22 18:55:47 +02:00
}