mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-08 12:00:53 +01:00
15 lines
548 B
TypeScript
15 lines
548 B
TypeScript
/* Helps replace t.co links with their originals */
|
|
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);
|
|
});
|
|
|
|
/* Remove any link with unavailable original.
|
|
This means that stuff like the t.co link to pic.twitter.com
|
|
will get removed in image/video Tweets */
|
|
text = text.replace(/ ?https:\/\/t\.co\/\w{10}/g, '');
|
|
}
|
|
|
|
return text;
|
|
};
|