this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add more unfurling

- Fix regex
- Handle trunks.social and Phanpy links too

+21 -5
+17 -3
src/components/status.jsx
··· 2158 2158 2159 2159 let remoteInstanceFetch; 2160 2160 let theURL = url; 2161 - if (/\/\/elk\.[^\/]+\/[^.]+\.[^.]+/i.test(theURL)) { 2162 - // E.g. https://elk.zone/domain.com/@stest/123 -> https://domain.com/@stest/123 2161 + 2162 + // https://elk.zone/domain.com/@stest/123 -> https://domain.com/@stest/123 2163 + if (/\/\/elk\.[^\/]+\/[^\/]+\.[^\/]+/i.test(theURL)) { 2163 2164 theURL = theURL.replace(/elk\.[^\/]+\//i, ''); 2164 2165 } 2166 + 2167 + // https://trunks.social/status/domain.com/@stest/123 -> https://domain.com/@stest/123 2168 + if (/\/\/trunks\.[^\/]+\/status\/[^\/]+\.[^\/]+/i.test(theURL)) { 2169 + theURL = theURL.replace(/trunks\.[^\/]+\/status\//i, ''); 2170 + } 2171 + 2172 + // https://phanpy.social/#/domain.com/s/123 -> https://domain.com/statuses/123 2173 + if (/\/#\/[^\/]+\.[^\/]+\/s\/.+/i.test(theURL)) { 2174 + const urlAfterHash = theURL.split('/#/')[1]; 2175 + const finalURL = urlAfterHash.replace(/\/s\//i, '/@fakeUsername/'); 2176 + theURL = `https://${finalURL}`; 2177 + } 2178 + 2165 2179 const urlObj = new URL(theURL); 2166 2180 const domain = urlObj.hostname; 2167 2181 const path = urlObj.pathname; ··· 2189 2203 const { masto } = api({ instance }); 2190 2204 const mastoSearchFetch = masto.v2.search 2191 2205 .fetch({ 2192 - q: url, 2206 + q: theURL, 2193 2207 type: 'statuses', 2194 2208 resolve: true, 2195 2209 limit: 1,
+4 -2
src/utils/isMastodonLinkMaybe.jsx
··· 1 1 export default function isMastodonLinkMaybe(url) { 2 - const { pathname } = new URL(url); 2 + const { pathname, hash } = new URL(url); 3 3 return ( 4 4 /^\/.*\/\d+$/i.test(pathname) || 5 5 /^\/@[^/]+\/(statuses|posts)\/\w+\/?$/i.test(pathname) || // GoToSocial, Takahe 6 6 /^\/notes\/[a-z0-9]+$/i.test(pathname) || // Misskey, Calckey 7 - /^\/(notice|objects)\/[a-z0-9-]+$/i.test(pathname) // Pleroma 7 + /^\/notes\/[a-z0-9]+$/i.test(pathname) || // Misskey, Calckey 8 + /^\/(notice|objects)\/[a-z0-9-]+$/i.test(pathname) || // Pleroma 9 + /#\/[^\/]+\.[^\/]+\/s\/.+/i.test(hash) // Phanpy 🫣 8 10 ); 9 11 }