diff --git a/gitea/gitea.go b/gitea/gitea.go index 5551719..e6cbd8d 100644 --- a/gitea/gitea.go +++ b/gitea/gitea.go @@ -47,28 +47,34 @@ func (c *Client) Open(user, path string) (fs.File, error) { log.Printf("user: %s", user) log.Printf("path: %s", path) - var repo string + var ( + repo string + filepath string + ) parts := strings.Split(strings.TrimLeft(path, "/"), "/") log.Printf("parts: %d #%v", len(parts), parts) if len(parts) > 1 { repo = parts[0] - path = strings.Join(parts[1:], "/") + filepath = strings.Join(parts[1:], "/") } else { repo = fmt.Sprintf("%s.%s", user, c.domain) + filepath = path } log.Printf("repo: %s", repo) // if path is empty they want to have the index.html - if path == "" || path == "/" { - path = "index.html" + if filepath == "" || filepath == "/" { + filepath = "index.html" } allowed := c.allowsPages(user, repo) log.Printf("allowed? %t", allowed) if !allowed && repo != fmt.Sprintf("%s.%s", user, c.domain) { repo = fmt.Sprintf("%s.%s", user, c.domain) - if !c.allowsPages(user, repo) { + if c.allowsPages(user, repo) { + filepath = path + } else { return nil, fs.ErrNotExist } }