| // Copyright 2019 The Go Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style | |
| // license that can be found in the LICENSE file. | |
| package frontend | |
| import ( | |
| "net/http" | |
| "strings" | |
| ) | |
| // handlePackageDetailsRedirect redirects all redirects to "/pkg" to "/". | |
| func (s *Server) handlePackageDetailsRedirect(w http.ResponseWriter, r *http.Request) { | |
| urlPath := strings.TrimPrefix(r.URL.Path, "/pkg") | |
| http.Redirect(w, r, urlPath, http.StatusMovedPermanently) | |
| } | |
| // handleModuleDetailsRedirect redirects all redirects to "/mod" to "/". | |
| func (s *Server) handleModuleDetailsRedirect(w http.ResponseWriter, r *http.Request) { | |
| urlPath := strings.TrimPrefix(r.URL.Path, "/mod") | |
| http.Redirect(w, r, urlPath, http.StatusMovedPermanently) | |
| } |