tail-fin-twitter 0.5.1

Twitter/X adapter for tail-fin: timeline, search, profile, bookmarks, likes, thread, post, like, follow, block, bookmark, reply, trending, lists, article, download, notifications
Documentation
/// Extract a tweet ID from a URL or bare ID.
///
/// Supports:
/// - `https://x.com/user/status/123456`
/// - `https://twitter.com/user/status/123456`
/// - Bare numeric ID
pub fn extract_tweet_id(input: &str) -> String {
    if let Some(cap) = input.find("/status/") {
        let after = &input[cap + 8..];
        after.chars().take_while(|c| c.is_ascii_digit()).collect()
    } else {
        input.to_string()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_extract_from_x_url() {
        assert_eq!(
            extract_tweet_id("https://x.com/nasa/status/1234567890"),
            "1234567890"
        );
    }

    #[test]
    fn test_extract_from_twitter_url() {
        assert_eq!(
            extract_tweet_id("https://twitter.com/user/status/9876543210?s=20"),
            "9876543210"
        );
    }

    #[test]
    fn test_extract_bare_id() {
        assert_eq!(extract_tweet_id("1234567890"), "1234567890");
    }
}