From 4f3a200e6525c9e6075c1daf3b78db03703be22a Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 2 Nov 2019 05:43:25 +0100 Subject: get_urls_from_pdf: Extract link annotation check to a function Give this condition a more descriptive name. --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 227911a..fb0b75d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ pub fn get_urls_from_pdf>(path: P) -> Result> { for (k, v) in d.iter() { let key = str::from_utf8(&k)?; - if key == "A" { + if object_is_link_annotation(key) { let url_objects = v.as_dict()?; for (k, v) in url_objects { @@ -50,6 +50,11 @@ pub fn get_urls_from_pdf>(path: P) -> Result> { Ok(urls) } +/// Returns true if the given PDF object key is a link annotation. +fn object_is_link_annotation(key: &str) -> bool { + key == "A" +} + #[cfg(test)] mod tests { -- cgit v1.2.3