1
0
dwelling-files/pkg/files/curpath.go

21 lines
410 B
Go
Raw Normal View History

package files
import (
"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("/\">")
2022-06-28 01:59:22 +04:00
sb.WriteString(part)
sb.WriteString("</a>")
curPath += sb.String()
}
return
}