diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2022-06-04 16:57:57 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2022-06-04 16:57:57 +0100 |
| commit | b52c712770dbc9b0b0adb8a106427fa59a9de7f8 (patch) | |
| tree | c8f36864e70eae2c1fa775429ab4cf953b833aa9 /resp.go | |
| parent | d90994408fed47a8fb7a2d82e2f751d8da7067e4 (diff) | |
Return 404 when the package name does not match
Diffstat (limited to 'resp.go')
| -rw-r--r-- | resp.go | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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) |
