aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jvoisin <julien.voisin@dustri.org> 2024-03-18 10:56:26 +0100
committerGravatar Frédéric Guillot <f@miniflux.net> 2024-03-18 16:09:32 -0700
commit91f5522ce01518ddb0e1df2cda8a54099959faab (patch)
tree45957a2e5faa70ef2cd7d8f43dd31d2f986f6ddd
parent8212f16aa21015f9c81ea6caa72996f4c55cef7e (diff)
downloadv2-91f5522ce01518ddb0e1df2cda8a54099959faab.tar.gz
v2-91f5522ce01518ddb0e1df2cda8a54099959faab.tar.zst
v2-91f5522ce01518ddb0e1df2cda8a54099959faab.zip
Minor simplification of internal/reader/media/media.go
- Simplify a switch-case by moving a common condition above it. - Remove a superfluous error-check: `strconv.ParseInt` returns `0` when passed an empty string.
-rw-r--r--internal/reader/media/media.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/internal/reader/media/media.go b/internal/reader/media/media.go
index 6dc208a2..736fc06c 100644
--- a/internal/reader/media/media.go
+++ b/internal/reader/media/media.go
@@ -86,15 +86,17 @@ type Content struct {
// MimeType returns the attachment mime type.
func (mc *Content) MimeType() string {
- switch {
- case mc.Type == "" && mc.Medium == "image":
+ if mc.Type != "" {
+ return mc.Type
+ }
+
+ switch mc.Medium {
+ case "image":
return "image/*"
- case mc.Type == "" && mc.Medium == "video":
+ case "video":
return "video/*"
- case mc.Type == "" && mc.Medium == "audio":
+ case "audio":
return "audio/*"
- case mc.Type != "":
- return mc.Type
default:
return "application/octet-stream"
}
@@ -102,9 +104,6 @@ func (mc *Content) MimeType() string {
// Size returns the attachment size.
func (mc *Content) Size() int64 {
- if mc.FileSize == "" {
- return 0
- }
size, _ := strconv.ParseInt(mc.FileSize, 10, 0)
return size
}