internal/frontend: redirect /vuln to /vuln/list

Change-Id: I70f126ef2a442ac499a78fe4773758bf3831630b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/382155
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/frontend/redirect.go b/internal/frontend/redirect.go
index aa26648..c39b5c8 100644
--- a/internal/frontend/redirect.go
+++ b/internal/frontend/redirect.go
@@ -26,6 +26,11 @@
 	http.Redirect(w, r, urlPath, http.StatusMovedPermanently)
 }
 
+// handleVulnRedirect redirects /vuln to /vuln/list.
+func (s *Server) handleVulnRedirect(w http.ResponseWriter, r *http.Request) {
+	http.Redirect(w, r, "/vuln/list", http.StatusFound)
+}
+
 // stdlibPathForShortcut returns a path in the stdlib that shortcut should redirect to,
 // or the empty string if there is no such path.
 func stdlibPathForShortcut(ctx context.Context, db *postgres.DB, shortcut string) (path string, err error) {
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index 63945fe..26bf102 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -169,6 +169,7 @@
 	}))
 	handle("/golang.org/x", s.staticPageHandler("subrepo", "Sub-repositories"))
 	handle("/files/", http.StripPrefix("/files", s.fileMux))
+	handle("/vuln", http.HandlerFunc(s.handleVulnRedirect))
 	handle("/vuln/", http.StripPrefix("/vuln", s.errorHandler(s.serveVuln)))
 	handle("/", detailHandler)
 	if s.serveStats {
diff --git a/internal/frontend/server_test.go b/internal/frontend/server_test.go
index c1ef69e..1099a48 100644
--- a/internal/frontend/server_test.go
+++ b/internal/frontend/server_test.go
@@ -1064,6 +1064,12 @@
 				notIn(".Documentation-variables"),
 				notIn(".UnitBuildContext-titleContext")),
 		},
+		{
+			name:           "vuln redirect",
+			urlPath:        "/vuln",
+			wantStatusCode: http.StatusFound,
+			wantLocation:   "/vuln/list",
+		},
 	}
 }