From f0a610c2acb78b2acb6888ff450163108780b18d Mon Sep 17 00:00:00 2001 From: Kenneth Gitere Date: Tue, 9 Feb 2021 12:56:07 +0300 Subject: [PATCH] Bug fix with empty titles The code for title retrieval previously assumed that meta tags concerned with the title would always contain a value but some sites leave the value empty thus it had to be checked for as well. --- src/moz_readability/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/moz_readability/mod.rs b/src/moz_readability/mod.rs index 7986c2b..9b25b79 100644 --- a/src/moz_readability/mod.rs +++ b/src/moz_readability/mod.rs @@ -462,7 +462,12 @@ impl Readability { .iter() .find(|key| values.contains_key(**key)) { - values.get(*key).map(|title| title.to_owned()).unwrap() + let title = values.get(*key).map(|title| title.to_owned()).unwrap(); + if title.is_empty() { + self.get_article_title() + } else { + title + } } else { self.get_article_title() };