From ca7c8fa2a04149cd40d8e32e3736f8671db66d9e Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sat, 17 Oct 2026 12:41:37 +1100 Subject: [PATCH] Serve gems api/v1 JSON as application/json --- internal/provider/gems/gems.go | 3 +++ internal/provider/gems/gems_test.go | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) 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 {