From 2da420399a57d76097102764e1918fc1f8cdc296 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sun, 4 Feb 2024 23:05:08 +0900 Subject: [PATCH] Add support for YAML media type in isBinary function --- ridgenative.go | 6 ++++++ ridgenative_test.go | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ridgenative.go b/ridgenative.go index cf52a18..ca4bb9f 100644 --- a/ridgenative.go +++ b/ridgenative.go @@ -378,6 +378,9 @@ func isBinary(contentType string) bool { if strings.EqualFold(mediaType, "application/json") { return false } + if strings.EqualFold(mediaType, "application/yaml") { + return false + } if strings.EqualFold(mediaType, "application/javascript") { return false } @@ -393,6 +396,9 @@ func isBinary(contentType string) bool { if strings.EqualFold(suffix, "+json") { return false } + if strings.EqualFold(suffix, "+yaml") { + return false + } if strings.EqualFold(suffix, "+xml") { return false } diff --git a/ridgenative_test.go b/ridgenative_test.go index 810548b..abacbb4 100644 --- a/ridgenative_test.go +++ b/ridgenative_test.go @@ -960,10 +960,12 @@ func TestIsBinary(t *testing.T) { {"text/xml", false}, {"application/json", false}, {"application/javascript", false}, + {"application/yaml", false}, {"application/xml", false}, - {"application/foo+json", false}, - {"application/foo+xml", false}, - {"application/foo+xml ; charset=utf8", false}, + {"application/vnd.foo+json", false}, + {"application/vnd.foo+yaml", false}, + {"application/vnd.foo+xml", false}, + {"application/vnd.foo+xml ; charset=utf8", false}, {"application/octet-stream", true}, {"image/jpeg", true}, {"audio/mpeg", true},