Looks like CurrentPath() func is complete.
This commit is contained in:
parent
ca6e28b376
commit
5f2b69ee3c
21
pkg/files/curpath.go
Normal file
21
pkg/files/curpath.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package files
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CurrentPath(path string) (curPath string) {
|
||||||
|
parts := strings.Split(path, "/")[1:]
|
||||||
|
curPath = "<a href=\"/\">root</a>"
|
||||||
|
for i, part := range parts {
|
||||||
|
var sb strings.Builder
|
||||||
|
sb.WriteString("/<a href=\"/")
|
||||||
|
sb.WriteString(strings.Join(parts[:i+1], "/"))
|
||||||
|
sb.WriteString("/\">")
|
||||||
|
sb.WriteString(url.PathEscape(part))
|
||||||
|
sb.WriteString("</a>")
|
||||||
|
curPath += sb.String()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user