Add www redirect for main domain

pull/13/head v2.2
Moritz Marquardt 2021-12-02 00:00:00 +01:00
rodzic a48ba8ee49
commit 26dd1591f6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: D5788327BEE388B6
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -180,6 +180,12 @@ func handler(ctx *fasthttp.RequestCtx) {
targetRepo = pathElements[0]
targetPath = strings.Trim(strings.Join(pathElements[1:], "/"), "/")
if targetOwner == "www" {
// www.codeberg.page redirects to codeberg.page
ctx.Redirect("https://" + string(MainDomainSuffix[1:]) + string(ctx.Path()), fasthttp.StatusPermanentRedirect)
return
}
// Check if the first directory is a repo with the second directory as a branch
// example.codeberg.page/myrepo/@main/index.html
if len(pathElements) > 1 && strings.HasPrefix(pathElements[1], "@") {