diff --git a/internal/provider/gems/gems.go b/internal/provider/gems/gems.go index 64ae038..39d324e 100644 --- a/internal/provider/gems/gems.go +++ b/internal/provider/gems/gems.go @@ -33,6 +33,9 @@ func (p *Provider) ContentType(path string) string { if path == "versions" || path == "names" || strings.HasPrefix(path, "info/") { return "text/plain; charset=utf-8" } + if strings.HasPrefix(path, "api/v1/") && strings.HasSuffix(path, ".json") { + return "application/json" + } return "application/octet-stream" } diff --git a/internal/provider/gems/gems_test.go b/internal/provider/gems/gems_test.go index 297d99f..9707bb3 100644 --- a/internal/provider/gems/gems_test.go +++ b/internal/provider/gems/gems_test.go @@ -36,11 +36,14 @@ func TestClassify(t *testing.T) { func TestContentType(t *testing.T) { p := &Provider{} tests := map[string]string{ - "versions": "text/plain; charset=utf-8", - "info/rack": "text/plain; charset=utf-8", - "names": "text/plain; charset=utf-8", - "gems/rack-3.1.8.gem": "application/octet-stream", - "specs.4.8.gz": "application/octet-stream", + "versions": "text/plain; charset=utf-8", + "info/rack": "text/plain; charset=utf-8", + "names": "text/plain; charset=utf-8", + "gems/rack-3.1.8.gem": "application/octet-stream", + "specs.4.8.gz": "application/octet-stream", + "api/v1/gems/rack.json": "application/json", + "api/v1/dependencies.json": "application/json", + "api/v1/dependencies": "application/octet-stream", } for path, want := range tests { if got := p.ContentType(path); got != want {