Redirect domain.tld/project to domain.tld/project/ when present.

This is to match the behavior of GitHub, as well as because it isn't
particularly useful to serve a file from the index repo with the same
path segment as the project name (and quite confusing too).
This commit is contained in:
Catherine
2025-11-18 22:25:26 +00:00
parent 325c283e05
commit 073435aa2b

View File

@@ -107,11 +107,15 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
err = nil
sitePath = strings.TrimPrefix(r.URL.Path, "/")
if projectName, projectPath, found := strings.Cut(sitePath, "/"); found {
if projectName, projectPath, hasProjectSlash := strings.Cut(sitePath, "/"); projectName != "" {
var projectManifest *Manifest
projectManifest, err = backend.GetManifest(r.Context(), makeWebRoot(host, projectName),
GetManifestOptions{BypassCache: bypassCache})
if err == nil {
if !hasProjectSlash {
writeRedirect(w, http.StatusFound, r.URL.Path+"/")
return nil
}
sitePath, manifest = projectPath, projectManifest
}
}