Skip to content

Commit fe076f2

Browse files
fix: Repositories with *.svg can't be rendered (#252)
closes #139
1 parent 05fc419 commit fe076f2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log/slog"
66
"net/http"
77
"os"
8+
"strings"
89
"time"
910

1011
"github.com/caarlos0/starcharts/config"
@@ -48,6 +49,9 @@ func main() {
4849
Handler(http.FileServer(http.FS(static)))
4950
r.Path("/{owner}/{repo}.svg").
5051
Methods(http.MethodGet).
52+
MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool {
53+
return !strings.Contains(r.Header.Get("Accept"), "text/html")
54+
}).
5155
Handler(controller.GetRepoChart(github, cache))
5256
r.Path("/{owner}/{repo}").
5357
Methods(http.MethodGet).

0 commit comments

Comments
 (0)