(DirectoryItemPath string)
| 3 | import "strings" |
| 4 | |
| 5 | func GetParentPath(DirectoryItemPath string) string { |
| 6 | DirectoryItemPath = strings.ReplaceAll(DirectoryItemPath, "\\", "/") |
| 7 | lastIndex := strings.LastIndex(DirectoryItemPath, "/") |
| 8 | |
| 9 | if lastIndex == -1 { |
| 10 | return DirectoryItemPath |
| 11 | } |
| 12 | |
| 13 | item := DirectoryItemPath[0:lastIndex] |
| 14 | |
| 15 | if len(item) > 1 { |
| 16 | return item |
| 17 | } else { |
| 18 | return DirectoryItemPath[0 : lastIndex+1] |
| 19 | } |
| 20 | } |
no outgoing calls
no test coverage detected