diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-03-11 20:55:40 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-03-11 20:55:40 +0100 |
| commit | 8e40e919aca8b8592be43e2c5bbcc0717bf14a6b (patch) | |
| tree | 506ac34b7e22cdb95568cef9e649ee64cb3b0fdb /src/plugins/url.rs | |
| parent | 9be7f31ee2d37800c7d23a9fff7d7ab8a2e076ed (diff) | |
| download | frippy-8e40e919aca8b8592be43e2c5bbcc0717bf14a6b.tar.gz frippy-8e40e919aca8b8592be43e2c5bbcc0717bf14a6b.zip | |
Consider title tags with attributes
Diffstat (limited to 'src/plugins/url.rs')
| -rw-r--r-- | src/plugins/url.rs | 18 |
1 files changed, 14 insertions, 4 deletions
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<String, UrlError> { - let title = body.find("<title>") - .map(|start| body.find("</title>").map(|end| &body[start + 7..end])) - .and_then(|s| s).ok_or(ErrorKind::MissingTitle)?; - + let title = body.find("<title") + .map(|tag| { + body[tag..] + .find('>') + .map(|offset| tag + offset + 1) + .map(|start| { + body[start..] + .find("</title>") + .map(|offset| start + offset) + .map(|end| &body[start..end]) + }) + }) + .and_then(|s| s.and_then(|s| s)) + .ok_or(ErrorKind::MissingTitle)?; debug!("Title: {:?}", title); |
