1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00

Force specific Content-Type value for JS (#6)

This commit is contained in:
Lukas Schulte Pelkum 2021-04-29 14:57:08 +02:00
parent 542bb5b17d
commit 5f7df183b4
No known key found for this signature in database
GPG Key ID: 408DA7CA81DB885C

View File

@ -31,6 +31,9 @@ func Serve() error {
router.GET("/{path:*}", func(ctx *fasthttp.RequestCtx) { router.GET("/{path:*}", func(ctx *fasthttp.RequestCtx) {
path := string(ctx.Path()) path := string(ctx.Path())
if !strings.HasPrefix(path, "/api") && (strings.Count(path, "/") == 1 || strings.HasPrefix(path, "/assets")) { if !strings.HasPrefix(path, "/api") && (strings.Count(path, "/") == 1 || strings.HasPrefix(path, "/assets")) {
if strings.HasPrefix(path, "/assets/js/") {
ctx.SetContentType("text/javascript")
}
frontend(ctx) frontend(ctx)
return return
} }