From de14a0e68d6524ebf9977ecb2050f1b4556b1d61 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sat, 6 Jan 2024 21:38:21 +0100 Subject: [PATCH] feat: Move the path modifications around --- cmd/rio/main.go | 8 ++++++++ internal/pages/pages.go | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/rio/main.go b/cmd/rio/main.go index 69858ab..12279b6 100644 --- a/cmd/rio/main.go +++ b/cmd/rio/main.go @@ -38,6 +38,14 @@ func handleSubdomain(domain, cname, path, giteaUrl, defaultCsp string, giteaClie 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( username, domain, diff --git a/internal/pages/pages.go b/internal/pages/pages.go index 685a84a..f203a48 100644 --- a/internal/pages/pages.go +++ b/internal/pages/pages.go @@ -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) { - // 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 if path[:1] == "/" { path = path[1:]