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

22 lines
437 B
Go

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
}