aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2019-11-02 05:43:25 +0100
committerTeddy Wing2019-11-02 05:43:25 +0100
commit4f3a200e6525c9e6075c1daf3b78db03703be22a (patch)
treeaf0c55d4aaa03c1c3267b0449f22ff0521ad9d54
parent99189e55a2fe4b14e269015f73b8d30a8e45ef2c (diff)
downloadpdf-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.rs7
1 files changed, 6 insertions, 1 deletions
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<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 {