mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 11:11:35 +00:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user