diff options
Diffstat (limited to 'object/tree/path_split.go')
| -rw-r--r-- | object/tree/path_split.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/object/tree/path_split.go b/object/tree/path_split.go new file mode 100644 index 00000000..c147dd25 --- /dev/null +++ b/object/tree/path_split.go @@ -0,0 +1,19 @@ +package tree + +import ( + "bytes" +) + +// SplitPath splits one slash-separated tree path into components. +func SplitPath(path []byte) [][]byte { + if len(path) == 0 { + return nil + } + + parts := bytes.Split(path, []byte{'/'}) + for i := range parts { + parts[i] = bytes.Clone(parts[i]) + } + + return parts +} |
