From 8e40e919aca8b8592be43e2c5bbcc0717bf14a6b Mon Sep 17 00:00:00 2001 From: Jokler Date: Sun, 11 Mar 2018 20:55:40 +0100 Subject: Consider title tags with attributes --- src/plugins/url.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/url.rs b/src/plugins/url.rs index e75d893..bff840f 100644 --- a/src/plugins/url.rs +++ b/src/plugins/url.rs @@ -37,10 +37,20 @@ impl Url { } fn get_title<'a>(&self, body: &str) -> Result { - let title = body.find("") - .map(|start| body.find("").map(|end| &body[start + 7..end])) - .and_then(|s| s).ok_or(ErrorKind::MissingTitle)?; - + let title = body.find("') + .map(|offset| tag + offset + 1) + .map(|start| { + body[start..] + .find("") + .map(|offset| start + offset) + .map(|end| &body[start..end]) + }) + }) + .and_then(|s| s.and_then(|s| s)) + .ok_or(ErrorKind::MissingTitle)?; debug!("Title: {:?}", title); -- cgit v1.2.3-70-g09d2