diff --git a/crates/archivr-core/src/capture.rs b/crates/archivr-core/src/capture.rs index ba66594..b974bf5 100644 --- a/crates/archivr-core/src/capture.rs +++ b/crates/archivr-core/src/capture.rs @@ -971,7 +971,7 @@ struct TweetJsonMetadata<'a> { #[serde(borrow)] author: Option>, #[serde(borrow)] - full_text: Option<&'a str>, + full_text: Option>, #[serde(borrow)] article: Option>, } @@ -979,13 +979,13 @@ struct TweetJsonMetadata<'a> { #[derive(serde::Deserialize)] struct TweetAuthorMetadata<'a> { #[serde(borrow)] - screen_name: Option<&'a str>, + screen_name: Option>, } #[derive(serde::Deserialize)] struct TweetArticleMetadata<'a> { #[serde(borrow)] - title: Option<&'a str>, + title: Option>, } fn tweet_metadata_from_json(json_str: &str) -> PlatformMetadata { @@ -3776,6 +3776,20 @@ mod tests { ); assert_eq!(meta.title, None); } + #[test] + fn tweet_title_extracted_from_json_with_escapes() { + let json = r#"{ + "full_text": "First line\n\nSecond line with \"quotes\"", + "author": { "screen_name": "rustacean", "name": "The Rustacean" } + }"#; + let meta = tweet_metadata_from_json(json); + assert_eq!(meta.author, Some("rustacean".to_string())); + assert_eq!( + meta.caption, + Some("First line\n\nSecond line with \"quotes\"".to_string()) + ); + assert_eq!(meta.title, None); + } #[test] fn tweet_prefers_article_title() {