diff options
author | Teddy Wing | 2019-11-02 05:43:25 +0100 |
---|---|---|
committer | Teddy Wing | 2019-11-02 05:43:25 +0100 |
commit | 4f3a200e6525c9e6075c1daf3b78db03703be22a (patch) | |
tree | af0c55d4aaa03c1c3267b0449f22ff0521ad9d54 | |
parent | 99189e55a2fe4b14e269015f73b8d30a8e45ef2c (diff) | |
download | pdf-urls-4f3a200e6525c9e6075c1daf3b78db03703be22a.tar.bz2 |
get_urls_from_pdf: Extract link annotation check to a function
Give this condition a more descriptive name.
-rw-r--r-- | src/lib.rs | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -23,7 +23,7 @@ pub fn get_urls_from_pdf<P: AsRef<Path>>(path: P) -> Result<Vec<String>> { 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<P: AsRef<Path>>(path: P) -> Result<Vec<String>> { 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 { |