aboutsummaryrefslogtreecommitdiff
path: root/internal/feed
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/feed/mail.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/internal/feed/mail.go b/internal/feed/mail.go
index 5f543e4..297aeff 100644
--- a/internal/feed/mail.go
+++ b/internal/feed/mail.go
@@ -14,6 +14,7 @@ import (
"github.com/PuerkitoBio/goquery"
"github.com/emersion/go-message"
"github.com/emersion/go-message/mail"
+ "github.com/gabriel-vasile/mimetype"
"github.com/Necoro/feed2imap-go/internal/feed/template"
"github.com/Necoro/feed2imap-go/pkg/config"
@@ -177,6 +178,10 @@ func (feed *Feed) ToMails(cfg *config.Config) ([]string, error) {
}
func getImage(src string) ([]byte, string) {
+ if strings.HasPrefix(src, "//") {
+ src = "https:" + src
+ }
+
resp, err := stdHTTPClient.Get(src)
if err != nil {
log.Errorf("Error fetching from '%s': %s", src, err)
@@ -190,14 +195,14 @@ func getImage(src string) ([]byte, string) {
return nil, ""
}
+ var mimeStr string
ext := path.Ext(src)
if ext == "" {
- log.Warnf("Cannot determine extension from '%s', skipping.", src)
- return nil, ""
+ mimeStr = mimetype.Detect(img).String()
+ } else {
+ mimeStr = mime.TypeByExtension(ext)
}
-
- mime := mime.TypeByExtension(ext)
- return img, mime
+ return img, mimeStr
}
func cidNr(idx int) string {
72377db9c853781593287f9cbcfa5&follow=1'>updated howtonecoro1-14/+24 2007-07-20new Plugin Schemenecoro1-5/+4 2007-07-20new Plugin Schemenecoro1-1/+1 2007-07-20new Plugin Schemenecoro9-162/+214 2007-07-13fixesnecoro4-27/+37 2007-07-13new fancier log outputnecoro14-127/+116 2007-07-11added SIGSTOP/SIGCONT support; SIGTERM now works ;)necoro8-208/+275 2007-07-09bug in shutdown pluginnecoro2-5/+12 2007-07-09added resume_loop pluginnecoro1-1/+1 2007-07-09added resume_loop pluginnecoro10-22/+162 2007-07-07some more documentationnecoro6-4/+108 2007-07-07Some documentation worknecoro7-18/+129