feat: Move the path modifications around
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
PapaTutuWawa 2024-01-06 21:38:21 +01:00
parent 40ce4e81a8
commit de14a0e68d
2 changed files with 8 additions and 8 deletions

View File

@ -38,6 +38,14 @@ func handleSubdomain(domain, cname, path, giteaUrl, defaultCsp string, giteaClie
path = path[1:] path = path[1:]
} }
// Provide a default file.
switch {
case path == "":
path = "/index.html"
case path[len(path)-1] == '/':
path = path + "index.html"
}
repo, path, err := repo.RepoFromPath( repo, path, err := repo.RepoFromPath(
username, username,
domain, domain,

View File

@ -38,14 +38,6 @@ func addHeaders(csp, contentType string, w http.ResponseWriter) {
} }
func ServeFile(username, reponame, path, defaultCsp string, giteaClient *repo.GiteaClient, w http.ResponseWriter) { func ServeFile(username, reponame, path, defaultCsp string, giteaClient *repo.GiteaClient, w http.ResponseWriter) {
// Provide a default file.
switch {
case path == "":
path = "/index.html"
case path[len(path)-1] == '/':
path = path + "index.html"
}
// Strip away a starting / as it messes with Gitea // Strip away a starting / as it messes with Gitea
if path[:1] == "/" { if path[:1] == "/" {
path = path[1:] path = path[1:]