1
0
Fork 0

Looks like CurrentPath() func is complete.

This commit is contained in:
Alexander Andreev 2022-06-27 23:36:45 +04:00
parent ca6e28b376
commit 5f2b69ee3c
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
1 changed files with 21 additions and 0 deletions

21
pkg/files/curpath.go Normal file
View 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
}