diff --git a/pkg/contexts/ocm/accessmethods/mvn/artifact.go b/pkg/contexts/ocm/accessmethods/mvn/artifact.go index 3fcd346476..72c0fbfc6b 100644 --- a/pkg/contexts/ocm/accessmethods/mvn/artifact.go +++ b/pkg/contexts/ocm/accessmethods/mvn/artifact.go @@ -4,6 +4,7 @@ import ( "strings" "github.com/open-component-model/ocm/pkg/mime" + "github.com/open-component-model/ocm/pkg/mimeutils" ) // Artifact holds the typical Maven coordinates groupId, artifactId, version and packaging. @@ -86,17 +87,9 @@ func (a *Artifact) ClassifierExtensionFrom(filename string) *Artifact { // MimeType returns the MIME type of the Maven Artifact based on the file extension. // Default is application/x-tgz. func (a *Artifact) MimeType() string { - switch a.Extension { - case "jar": - return mime.MIME_JAR - case "json", "module": - return mime.MIME_JSON - case "pom", "xml": - return mime.MIME_XML - case "tar.gz": - return mime.MIME_TGZ - case "zip": - return mime.MIME_GZIP + m := mimeutils.TypeByExtension("." + a.Extension) + if m != "" { + return m } return mime.MIME_TGZ } diff --git a/pkg/mimeutils/type.go b/pkg/mimeutils/type.go index cbd4c8bad1..8854545ae9 100644 --- a/pkg/mimeutils/type.go +++ b/pkg/mimeutils/type.go @@ -83,11 +83,16 @@ var builtinTypesLower = map[string]string{ ".webp": "image/webp", ".xml": "text/xml; charset=utf-8", // added entries - ".txt": ocmmime.MIME_TEXT, - ".yaml": ocmmime.MIME_YAML_OFFICIAL, - ".gzip": ocmmime.MIME_GZIP, - ".tar": ocmmime.MIME_TAR, - ".tgz": ocmmime.MIME_TGZ, + ".txt": ocmmime.MIME_TEXT, + ".yaml": ocmmime.MIME_YAML_OFFICIAL, + ".gzip": ocmmime.MIME_GZIP, + ".tar": ocmmime.MIME_TAR, + ".tgz": ocmmime.MIME_TGZ, + ".tar.gz": ocmmime.MIME_TGZ, + ".pom": ocmmime.MIME_XML, + ".zip": ocmmime.MIME_GZIP, + ".jar": ocmmime.MIME_JAR, + ".module": ocmmime.MIME_JSON, // gradle module metadata } var once sync.Once // guards initMime