mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-02 07:37:18 +03:00
15 lines
557 B
JavaScript
15 lines
557 B
JavaScript
export default function isMastodonLinkMaybe(url) {
|
|
try {
|
|
const { pathname, hash } = new URL(url);
|
|
return (
|
|
/^\/.*\/\d+$/i.test(pathname) ||
|
|
/^\/@[^/]+\/(statuses|posts)\/\w+\/?$/i.test(pathname) || // GoToSocial, Takahe
|
|
/^\/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 🫣
|
|
);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|