[#240] Fix native index page
All checks were successful
/ DCO (pull_request) Successful in 34s
/ Vulncheck (pull_request) Successful in 1m1s
/ Builds (pull_request) Successful in 1m7s
/ OCI image (pull_request) Successful in 1m26s
/ Lint (pull_request) Successful in 3m4s
/ Tests (pull_request) Successful in 1m17s
/ Integration tests (pull_request) Successful in 5m52s
All checks were successful
/ DCO (pull_request) Successful in 34s
/ Vulncheck (pull_request) Successful in 1m1s
/ Builds (pull_request) Successful in 1m7s
/ OCI image (pull_request) Successful in 1m26s
/ Lint (pull_request) Successful in 3m4s
/ Tests (pull_request) Successful in 1m17s
/ Integration tests (pull_request) Successful in 5m52s
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
39cf4e508e
commit
acf6c33b27
2 changed files with 9 additions and 21 deletions
|
@ -76,13 +76,13 @@ func newListObjectsResponseNative(attrs map[string]string) ResponseObject {
|
|||
}
|
||||
}
|
||||
|
||||
func getNextDir(filepath, prefix string) string {
|
||||
func getNextDir(filepath, prefix string) *string {
|
||||
restPath := strings.Replace(filepath, prefix, "", 1)
|
||||
index := strings.Index(restPath, "/")
|
||||
if index == -1 {
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
return restPath[:index]
|
||||
return ptr(restPath[:index])
|
||||
}
|
||||
|
||||
func lastPathElement(path string) string {
|
||||
|
@ -143,7 +143,7 @@ func getParent(encPrefix string) string {
|
|||
if slashIndex == -1 {
|
||||
return ""
|
||||
}
|
||||
return prefix[:slashIndex]
|
||||
return prefix[:slashIndex+1]
|
||||
}
|
||||
|
||||
func urlencode(path string) string {
|
||||
|
@ -259,7 +259,7 @@ func (h *Handler) getDirObjectsNative(ctx context.Context, bucketInfo *data.Buck
|
|||
if _, ok := dirs[objExt.Object.FileName]; ok {
|
||||
continue
|
||||
}
|
||||
objExt.Object.GetURL = "/get/" + bucketInfo.CID.EncodeToString() + urlencode(objExt.Object.FilePath)
|
||||
objExt.Object.GetURL = "/get/" + bucketInfo.CID.EncodeToString() + "/" + urlencode(objExt.Object.FilePath)
|
||||
dirs[objExt.Object.FileName] = struct{}{}
|
||||
} else {
|
||||
objExt.Object.GetURL = "/get/" + bucketInfo.CID.EncodeToString() + "/" + objExt.Object.OID
|
||||
|
@ -331,13 +331,13 @@ func (h *Handler) headDirObject(ctx context.Context, cnrID cid.ID, objID oid.ID,
|
|||
}
|
||||
|
||||
dirname := getNextDir(attrs[object.AttributeFilePath], basePath)
|
||||
if dirname == "" {
|
||||
if dirname == nil {
|
||||
return newListObjectsResponseNative(attrs), nil
|
||||
}
|
||||
|
||||
return ResponseObject{
|
||||
FileName: dirname,
|
||||
FilePath: basePath + dirname,
|
||||
FileName: *dirname,
|
||||
FilePath: basePath + *dirname,
|
||||
IsDir: true,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -56,27 +56,15 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{ $parentPrefix := getParent .Prefix }}
|
||||
{{if $parentPrefix }}
|
||||
<tr>
|
||||
<td>
|
||||
⮐<a href="/get/{{$container}}{{ urlencode $parentPrefix }}/">..</a>
|
||||
⮐<a href="/get/{{$container}}/{{ urlencode $parentPrefix }}">..</a>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td>
|
||||
⮐<a href="/get/{{$container}}/">..</a>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{range .Objects}}
|
||||
<tr>
|
||||
<td>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue