diff --git a/README.md b/README.md index bbc4927..111fee5 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ In many ways, FixTweet has richer embeds and does more. Here's a table comparing | Embed profile pictures on text Tweets | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | | Embed Twitter Videos | :heavy_check_mark: | :x:¹ | :heavy_check_mark: | :heavy_check_mark: | | Embed External Videos (YouTube, etc.) | :heavy_check_mark:⁵ | :x: | :x:⁴ | :x: | -| Embed Poll results | :heavy_check_mark: | :x: | :x: | :x: | +| Embed Poll results | :heavy_check_mark: | :x: | [:x:][polladd] | :x: | | Embed Quote Tweets | :heavy_check_mark: | :x: | :ballot_box_with_check: Without Media | :ballot_box_with_check: Without Media | | Embed Multiple Images | :heavy_check_mark: | :heavy_minus_sign: Discord Only³ | :ballot_box_with_check: c.vxtwitter.com | :x: | | Translate Tweets | :heavy_check_mark: | :x: | :x: | :x: | @@ -135,6 +135,7 @@ In many ways, FixTweet has richer embeds and does more. Here's a table comparing [fc]: https://github.com/FixTweet/FixTweet/commits [vc]: https://github.com/dylanpdx/BetterTwitFix/commits [sc]: https://github.com/Twxtter/Twxtter-main/commits +[polladd]: https://github.com/dylanpdx/BetterTwitFix/issues/17 ¹ Discord will attempt to embed Twitter's video player, but it is unreliable diff --git a/src/server.ts b/src/server.ts index 590b005..1d2de0f 100644 --- a/src/server.ts +++ b/src/server.ts @@ -45,7 +45,7 @@ const statusRequest = async ( Also note that all we're doing here is setting the direct flag. If someone links a video and ends it with .jpg, it will still redirect to a .mp4! */ - if ( url.pathname.match(/\/status(es)?\/\d{2,20}\.(mp4|png|jpe?g)/g)) { + if (url.pathname.match(/\/status(es)?\/\d{2,20}\.(mp4|png|jpe?g)/g)) { console.log('Direct media request by extension'); flags.direct = true; } else if (Constants.DIRECT_MEDIA_DOMAINS.includes(url.hostname)) { @@ -151,7 +151,7 @@ const profileRequest = async (request: Request) => { const genericTwitterRedirect = async (request: Request) => { const url = new URL(request.url); return Response.redirect(`${Constants.TWITTER_ROOT}${url.pathname}`, 302); -} +}; const versionRequest = async (request: Request) => { return new Response( diff --git a/src/status.ts b/src/status.ts index 7ee766e..5036f54 100644 --- a/src/status.ts +++ b/src/status.ts @@ -172,7 +172,9 @@ export const handleStatus = async ( /* Push the raw video-related headers */ headers.push( ``, - ``, + ``, ``, ``, ``, @@ -309,7 +311,10 @@ export const handleStatus = async ( if (tweet.replying_to && authorText === Strings.DEFAULT_AUTHOR_TEXT) { authorText = `↪ Replying to @${tweet.replying_to}`; /* We'll assume it's a thread if it's a reply to themselves */ - } else if (tweet.replying_to === tweet.author.screen_name && authorText === Strings.DEFAULT_AUTHOR_TEXT) { + } else if ( + tweet.replying_to === tweet.author.screen_name && + authorText === Strings.DEFAULT_AUTHOR_TEXT + ) { authorText = `↪ A part of @${tweet.author.screen_name}'s thread`; } diff --git a/test/index.test.ts b/test/index.test.ts index 6bd261c..da5cc51 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -39,13 +39,18 @@ test('Tweet redirect human', async () => { test('Twitter moment redirect', async () => { const result = await cacheWrapper( - new Request('https://fxtwitter.com/i/events/1572638642127966214?t=0UK7Ny-Jnsp-dUGzlb-M8w&s=35', { - method: 'GET', - headers: botHeaders - }) + new Request( + 'https://fxtwitter.com/i/events/1572638642127966214?t=0UK7Ny-Jnsp-dUGzlb-M8w&s=35', + { + method: 'GET', + headers: botHeaders + } + ) ); expect(result.status).toEqual(302); - expect(result.headers.get('location')).toEqual('https://twitter.com/i/events/1572638642127966214'); + expect(result.headers.get('location')).toEqual( + 'https://twitter.com/i/events/1572638642127966214' + ); }); test('Tweet response robot', async () => { @@ -152,9 +157,7 @@ test('API fetch multi-photo Tweet', async () => { const tweet = response.tweet as APITweet; expect(tweet).toBeTruthy(); - expect(tweet.url).toEqual( - 'https://twitter.com/Twitter/status/1445094085593866246' - ); + expect(tweet.url).toEqual('https://twitter.com/Twitter/status/1445094085593866246'); expect(tweet.id).toEqual('1445094085593866246'); expect(tweet.text).toEqual('@netflix'); expect(tweet.author.screen_name?.toLowerCase()).toEqual('twitter'); @@ -276,9 +279,7 @@ test('API fetch poll Tweet', async () => { const tweet = response.tweet as APITweet; expect(tweet).toBeTruthy(); - expect(tweet.url).toEqual( - 'https://twitter.com/Twitter/status/1055475950543167488' - ); + expect(tweet.url).toEqual('https://twitter.com/Twitter/status/1055475950543167488'); expect(tweet.id).toEqual('1055475950543167488'); expect(tweet.text).toEqual('A poll:'); expect(tweet.author.screen_name?.toLowerCase()).toEqual('twitter');