shithub: furgit

ref: df1f2fb3daa1acd25c88510f259d5535fb482126
dir: /object/tree/path_split.go/

View raw version
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
}