aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/util.go b/util.go
index 0ce512f..5d5de44 100644
--- a/util.go
+++ b/util.go
@@ -280,8 +280,10 @@ func getPaper(client *http.Client, u string) (string, error) {
if err != nil {
continue
}
- _u.Path = _v.Path
- dl = _u
+ if strings.HasSuffix(_v.Path, "pdf") {
+ _u.Path = _v.Path
+ dl = _u
+ }
}
}
}
@@ -300,6 +302,10 @@ func getPaper(client *http.Client, u string) (string, error) {
return "", err
}
+ if resp.Header.Get("content-type") != "application/pdf" {
+ return "", fmt.Errorf("%q: parsed PDF direct link not application/pdf", u)
+ }
+
tmpPDF, err := ioutil.TempFile("", "tmp-*.pdf")
if err != nil {
return "", err