From fd161455b4cb03e03c52f25d4bbf736723179a3c Mon Sep 17 00:00:00 2001 From: Philip Wrenn Date: Sat, 5 Jun 2021 23:17:55 -0400 Subject: [PATCH] Removed unwrap to prevent unexpected panic. --- src/moz_readability/mod.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/moz_readability/mod.rs b/src/moz_readability/mod.rs index 705fa55..7549f24 100644 --- a/src/moz_readability/mod.rs +++ b/src/moz_readability/mod.rs @@ -1609,13 +1609,8 @@ impl Readability { // // class name "comment", etc), and turn divs into P tags where they have been // // used inappropriately (as in, where they contain no other block level elements.) let mut elements_to_score: Vec = Vec::new(); - let mut node = Some( - self.root_node - .select_first("html") - .unwrap() - .as_node() - .clone(), - ); + let mut node = self.root_node.select_first("html") + .ok().map(|n| n.as_node().clone()); while let Some(node_ref) = node { let node_elem = node_ref.as_element().unwrap();