From dff1bdd295ecfbb75b358ce3b1aee5c25cc0aa1c Mon Sep 17 00:00:00 2001 From: Dhravya Date: Sun, 14 Jul 2024 10:24:00 -0500 Subject: [PATCH] quickfix: remove any instances of chunkings from raw tweets --- packages/shared-types/utils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/shared-types/utils.ts b/packages/shared-types/utils.ts index 6816d99a..c97d053c 100644 --- a/packages/shared-types/utils.ts +++ b/packages/shared-types/utils.ts @@ -12,10 +12,15 @@ export const tweetToMd = (tweet: Tweet) => { export const getRawTweet = (tweet: string) => { // Get the content inside the last tag, there can any number of tags in the tweet (or just one) - const rawTag = /(.*)<\/raw>/g; + const rawTag = /(.*)<\/raw>/gs; // Use 's' flag to match across multiple lines const match = rawTag.exec(tweet); - if (match) { - return match[1]; + if (match && match.length > 1) { + // Remove the specified item pattern + const cleanedContent = match[1]?.replace( + /<---chunkId:.*?\n.*?\n---->/gs, + "", + ); + return cleanedContent; } return tweet; };