From 78e105f3b224f5b1c5d82c24e2a610adce6f3016 Mon Sep 17 00:00:00 2001 From: bobo liu <7552030+fakeboboliu@users.noreply.github.com> Date: Wed, 8 Dec 2021 13:38:25 +0800 Subject: [PATCH] Chore: builtin right mime of .js (#1808) --- constant/mime/mime.go | 16 ++++++++++++++++ hub/route/server.go | 1 + 2 files changed, 17 insertions(+) create mode 100644 constant/mime/mime.go diff --git a/constant/mime/mime.go b/constant/mime/mime.go new file mode 100644 index 000000000..431457be8 --- /dev/null +++ b/constant/mime/mime.go @@ -0,0 +1,16 @@ +package mime + +import ( + "mime" +) + +var consensusMimes = map[string]string{ + // rfc4329: text/javascript is obsolete, so we need to overwrite mime's builtin + ".js": "application/javascript; charset=utf-8", +} + +func init() { + for ext, typ := range consensusMimes { + mime.AddExtensionType(ext, typ) + } +} diff --git a/hub/route/server.go b/hub/route/server.go index e01696bed..c38ca7e10 100644 --- a/hub/route/server.go +++ b/hub/route/server.go @@ -9,6 +9,7 @@ import ( "time" C "github.com/Dreamacro/clash/constant" + _ "github.com/Dreamacro/clash/constant/mime" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel/statistic"