File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,16 @@ const typeFile = template.HTML("file")
14
14
15
15
func updateSubItemsHtml (data * responseData ) {
16
16
length := len (data .SubItems )
17
+ if length == 0 {
18
+ return
19
+ }
17
20
data .SubItemsHtml = make ([]itemHtml , length )
18
21
22
+ dirSuffix := "/" + data .Context .QueryString ()
23
+ fileSuffix := data .Context .FileQueryString ()
24
+
19
25
for i , info := range data .SubItems {
20
26
name := info .Name ()
21
- urlEscapedName := tplUtil .FormatFileUrl (name )
22
27
23
28
var displayName template.HTML
24
29
var typ template.HTML
@@ -28,11 +33,11 @@ func updateSubItemsHtml(data *responseData) {
28
33
if info .IsDir () {
29
34
displayName = tplUtil .FormatFilename (name ) + "/"
30
35
typ = typeDir
31
- url = data .SubItemPrefix + urlEscapedName + "/" + data . Context . QueryString ()
36
+ url = data .SubItemPrefix + tplUtil . FormatFileUrl ( name ) + dirSuffix
32
37
} else {
33
38
displayName = tplUtil .FormatFilename (name )
34
39
typ = typeFile
35
- url = data .SubItemPrefix + urlEscapedName + data . Context . FileQueryString ()
40
+ url = data .SubItemPrefix + tplUtil . FormatFileUrl ( name ) + fileSuffix
36
41
readableSize = tplUtil .FormatSize (info .Size ())
37
42
}
38
43
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ type pathContext struct {
10
10
func (ctx pathContext ) QueryString () string {
11
11
// ?downloadfile&sort=x/&
12
12
buffer := make ([]byte , 1 , 22 )
13
- buffer [0 ] = '?'
13
+ buffer [0 ] = '?' // 1 byte
14
14
15
15
switch {
16
16
case ctx .downloadfile :
@@ -29,16 +29,16 @@ func (ctx pathContext) QueryString() string {
29
29
return string (buffer )
30
30
}
31
31
32
+ func (ctx pathContext ) QueryStringOfSort (sort string ) string {
33
+ copiedCtx := ctx
34
+ copiedCtx .sort = & sort
35
+ return copiedCtx .QueryString ()
36
+ }
37
+
32
38
func (ctx pathContext ) FileQueryString () string {
33
39
if ctx .downloadfile {
34
40
return "?downloadfile"
35
41
}
36
42
37
43
return ""
38
44
}
39
-
40
- func (ctx pathContext ) QueryStringOfSort (sort string ) string {
41
- copiedCtx := ctx
42
- copiedCtx .sort = & sort
43
- return copiedCtx .QueryString ()
44
- }
You can’t perform that action at this time.
0 commit comments