ipld-eth-server/vendor/github.com/libp2p/go-libp2p-record/util.go
Elizabeth Engelman 36533f7c3f Update vendor directory and make necessary code changes
Fixes for new geth version
2019-09-25 16:32:27 -05:00

23 lines
413 B
Go

package record
import (
"strings"
)
// SplitKey takes a key in the form `/$namespace/$path` and splits it into
// `$namespace` and `$path`.
func SplitKey(key string) (string, string, error) {
if len(key) == 0 || key[0] != '/' {
return "", "", ErrInvalidRecordType
}
key = key[1:]
i := strings.IndexByte(key, '/')
if i <= 0 {
return "", "", ErrInvalidRecordType
}
return key[:i], key[i+1:], nil
}