mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-15 11:09:06 +08:00
34 lines
529 B
Go
34 lines
529 B
Go
package filer_ui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
)
|
|
|
|
type Breadcrumb struct {
|
|
Name string
|
|
Link string
|
|
}
|
|
|
|
func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
|
|
parts := strings.Split(fullpath, "/")
|
|
|
|
for i := 0; i < len(parts); i++ {
|
|
name := parts[i]
|
|
if name == "" {
|
|
name = "/"
|
|
}
|
|
crumb := Breadcrumb{
|
|
Name: name,
|
|
Link: "/" + util.Join(parts[0:i+1]...),
|
|
}
|
|
if !strings.HasSuffix(crumb.Link, "/") {
|
|
crumb.Link += "/"
|
|
}
|
|
crumbs = append(crumbs, crumb)
|
|
}
|
|
|
|
return
|
|
}
|