From 372c7cf76b68c047a5135e439c8d43fd5c9fca52 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Wed, 31 May 2023 17:00:30 -0400 Subject: [PATCH] Remove extraneous /i/web/status --- src/helpers/linkFixer.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helpers/linkFixer.ts b/src/helpers/linkFixer.ts index 8dfb8e7..d28bcd9 100644 --- a/src/helpers/linkFixer.ts +++ b/src/helpers/linkFixer.ts @@ -2,7 +2,12 @@ export const linkFixer = (tweet: TweetPartial, text: string): string => { if (typeof tweet.entities?.urls !== 'undefined') { tweet.entities?.urls.forEach((url: TcoExpansion) => { - text = text.replace(url.url, url.expanded_url); + let newURL = url.expanded_url; + + if (newURL.match(/^https:\/\/twitter\.com\/i\/web\/status\/\w+/g) !== null) { + newURL = ''; + } + text = text.replace(url.url, newURL); }); /* Remove any link with unavailable original.