24 lines
467 B
Go
24 lines
467 B
Go
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 "/"
|
|
}
|