From 073435aa2b25272218ef32e8ba9d588fa4518994 Mon Sep 17 00:00:00 2001 From: Catherine Date: Tue, 18 Nov 2025 22:25:26 +0000 Subject: [PATCH] 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). --- src/pages.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages.go b/src/pages.go index e204de6..8991d2c 100644 --- a/src/pages.go +++ b/src/pages.go @@ -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 } }