Improve tweet read reliability and test coverage

This commit is contained in:
Peter Steinberger
2025-11-28 08:07:44 +01:00
parent b2dc418860
commit 5889044d7b
5 changed files with 125 additions and 67 deletions
+12
View File
@@ -0,0 +1,12 @@
/**
* Extract tweet ID from a Twitter/X URL or return the input unchanged if it's already an ID.
*/
export function extractTweetId(input: string): string {
// If it's a URL, extract the tweet ID
const urlMatch = input.match(/(?:twitter\.com|x\.com)\/\w+\/status\/(\d+)/);
if (urlMatch) {
return urlMatch[1];
}
// Assume it's already an ID
return input;
}