aboutsummaryrefslogtreecommitdiff
path: root/resp.go
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2022-06-04 16:57:57 +0100
committerGrégoire Duchêne <gduchene@awhk.org>2022-06-04 16:57:57 +0100
commitb52c712770dbc9b0b0adb8a106427fa59a9de7f8 (patch)
treec8f36864e70eae2c1fa775429ab4cf953b833aa9 /resp.go
parentd90994408fed47a8fb7a2d82e2f751d8da7067e4 (diff)
Return 404 when the package name does not match
Diffstat (limited to 'resp.go')
-rw-r--r--resp.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/resp.go b/resp.go
index b213f58..deae50a 100644
--- a/resp.go
+++ b/resp.go
@@ -35,6 +35,10 @@ func (h *redirector) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
pkg := path.Join(req.Host, req.URL.Path)
+ if !h.re.MatchString(pkg) {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
if req.URL.Query().Get("go-get") != "1" {
w.Header().Set("Location", "https://pkg.go.dev/"+pkg)
w.WriteHeader(http.StatusFound)