diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/mediaType.go | 6 | ||||
-rw-r--r-- | media/mediaType_test.go | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/media/mediaType.go b/media/mediaType.go index cdfb1c654..5732b9030 100644 --- a/media/mediaType.go +++ b/media/mediaType.go @@ -117,7 +117,7 @@ func FromContent(types Types, extensionHints []string, content []byte) Type { // FromStringAndExt creates a Type from a MIME string and a given extension. func FromStringAndExt(t, ext string) (Type, error) { - tp, err := fromString(t) + tp, err := FromString(t) if err != nil { return tp, err } @@ -129,7 +129,7 @@ func FromStringAndExt(t, ext string) (Type, error) { // FromString creates a new Type given a type string on the form MainType/SubType and // an optional suffix, e.g. "text/html" or "text/html+html". -func fromString(t string) (Type, error) { +func FromString(t string) (Type, error) { t = strings.ToLower(t) parts := strings.Split(t, "/") if len(parts) != 2 { @@ -470,7 +470,7 @@ func DecodeTypes(mms ...map[string]any) (Types, error) { mediaType, found := mmm[k] if !found { var err error - mediaType, err = fromString(k) + mediaType, err = FromString(k) if err != nil { return m, err } diff --git a/media/mediaType_test.go b/media/mediaType_test.go index 2a1b48849..3d12c31bb 100644 --- a/media/mediaType_test.go +++ b/media/mediaType_test.go @@ -132,22 +132,22 @@ func TestGetFirstBySuffix(t *testing.T) { func TestFromTypeString(t *testing.T) { c := qt.New(t) - f, err := fromString("text/html") + f, err := FromString("text/html") c.Assert(err, qt.IsNil) c.Assert(f.Type(), qt.Equals, HTMLType.Type()) - f, err = fromString("application/custom") + f, err = FromString("application/custom") c.Assert(err, qt.IsNil) c.Assert(f, qt.Equals, Type{MainType: "application", SubType: "custom", mimeSuffix: ""}) - f, err = fromString("application/custom+sfx") + f, err = FromString("application/custom+sfx") c.Assert(err, qt.IsNil) c.Assert(f, qt.Equals, Type{MainType: "application", SubType: "custom", mimeSuffix: "sfx"}) - _, err = fromString("noslash") + _, err = FromString("noslash") c.Assert(err, qt.Not(qt.IsNil)) - f, err = fromString("text/xml; charset=utf-8") + f, err = FromString("text/xml; charset=utf-8") c.Assert(err, qt.IsNil) c.Assert(f, qt.Equals, Type{MainType: "text", SubType: "xml", mimeSuffix: ""}) |