personal-website/webfs/utils.go

24 lines
467 B
Go
Raw Permalink Normal View History

2023-11-24 19:12:13 +00:00
package webfs
import "strings"
func SplitPath(path string) []string {
var resPath []string
splittedPath := strings.Split(path, "/")
splittedPath[0] = "/"
for _, split := range splittedPath {
if split != "" {
resPath = append(resPath, split)
}
}
return resPath
}
func GetParentPath(path string) string {
splittedPath := SplitPath(path)
if len(splittedPath) > 1 {
return "/" + strings.Join(splittedPath[1:len(splittedPath)-1], "/")
}
return "/"
}