aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/handler')
-rw-r--r--pkg/handler/git/handler.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go
index fd62e44..5e50122 100644
--- a/pkg/handler/git/handler.go
+++ b/pkg/handler/git/handler.go
@@ -233,6 +233,12 @@ func (g *GitHandler) Tree(w http.ResponseWriter, r *http.Request) error {
name := r.PathValue("name")
ref := r.PathValue("ref")
rest := r.PathValue("rest")
+ paths := []string{}
+
+ // this is avoid Split from generating a len 1 array with empty string
+ if rest != "" {
+ paths = strings.Split(rest, "/")
+ }
tree, err := g.gitService.GetTree(name, ref, rest)
if err != nil {
@@ -243,8 +249,8 @@ func (g *GitHandler) Tree(w http.ResponseWriter, r *http.Request) error {
Name: name,
Ref: ref,
GitItemBase: &templates.GitItemTreePage{
- CurrentPath: rest,
- Tree: tree,
+ Path: paths,
+ Tree: tree,
},
}
templates.WritePageTemplate(w, gitList)
@@ -256,6 +262,12 @@ func (g *GitHandler) Blob(w http.ResponseWriter, r *http.Request) error {
name := r.PathValue("name")
ref := r.PathValue("ref")
rest := r.PathValue("rest")
+ paths := []string{}
+
+ // this is avoid Split from generating a len 1 array with empty string
+ if rest != "" {
+ paths = strings.Split(rest, "/")
+ }
isBin, err := g.gitService.IsBinary(name, ref, rest)
if err != nil {
@@ -268,7 +280,7 @@ func (g *GitHandler) Blob(w http.ResponseWriter, r *http.Request) error {
Name: name,
Ref: ref,
GitItemBase: &templates.GitItemBlobPage{
- File: rest,
+ Path: paths,
Content: []byte("Binary file"),
},
}
@@ -303,7 +315,7 @@ func (g *GitHandler) Blob(w http.ResponseWriter, r *http.Request) error {
Name: name,
Ref: ref,
GitItemBase: &templates.GitItemBlobPage{
- File: rest,
+ Path: paths,
Content: code.Bytes(),
},
}