Test this out for bridgy fed links

This commit is contained in:
Lim Chee Aun 2024-07-21 19:06:38 +08:00
parent 00e2ba0b34
commit b88376569e

View file

@ -1,6 +1,6 @@
export default function isMastodonLinkMaybe(url) {
try {
const { pathname, hash } = URL.parse(url);
const { pathname, hash, hostname } = URL.parse(url);
return (
/^\/.*\/\d+$/i.test(pathname) ||
/^\/(@[^/]+|users\/[^/]+)\/(statuses|posts)\/\w+\/?$/i.test(pathname) || // GoToSocial, Takahe
@ -8,6 +8,7 @@ export default function isMastodonLinkMaybe(url) {
/^\/(notice|objects)\/[a-z0-9-]+$/i.test(pathname) || // Pleroma
/^\/@[^/]+\/post\/[a-z0-9]+$/i.test(pathname) || // Threads
/^\/@[^/]+\/[a-z0-9]+[a-z0-9\-]+[a-z0-9]+$/i.test(pathname) || // Hollo
(hostname === 'fed.brid.gy' && pathname.startsWith('/r/http')) || // Bridgy Fed
/#\/[^\/]+\.[^\/]+\/s\/.+/i.test(hash) // Phanpy 🫣
);
} catch (e) {