phanpy/src/utils/isMastodonLinkMaybe.jsx

10 lines
359 B
React
Raw Normal View History

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