Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit 246acf2

Browse files
committed
Fix file path bug
1 parent bd9ee63 commit 246acf2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

routers/api/v1/repo/tree.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net/http"
99
"net/url"
10+
"path/filepath"
1011
"strings"
1112

1213
"code.gitea.io/gitea/modules/base"
@@ -59,6 +60,7 @@ func getDirectoryEntries(ctx *context.APIContext, branch, path string) ([]struct
5960
Commit: commit,
6061
}
6162
commits = append(commits, commitInfo)
63+
path = filepath.Dir(path)
6264

6365
} else {
6466
tree, err := ctx.Repo.Commit.SubTree(path)
@@ -82,7 +84,7 @@ func getDirectoryEntries(ctx *context.APIContext, branch, path string) ([]struct
8284
for _, c := range commits {
8385
e := structs.GitEntry{
8486
Name: c.Entry.Name(),
85-
Path: path + "/" + c.Entry.Name(),
87+
Path: filepath.Join(path, c.Entry.Name()),
8688
Mode: c.Entry.Mode().String(),
8789
Type: c.Entry.Type(),
8890
Size: c.Entry.Size(),

0 commit comments

Comments
 (0)