Make split function path package public (#1485)

## Description

Want to use the `split` function through the path package to split arbitrary escaped strings. 

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [X] 🐹 Trivial/Minor

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #<issue>

## Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [X]  Unit test
- [ ] 💚 E2E

Existing unit tests pass.
This commit is contained in:
Rajat Kateja 2022-11-16 15:55:33 -08:00 committed by GitHub
parent e02da9d108
commit 80bbbdb87d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -338,7 +338,7 @@ func FromDataLayerPath(p string, isItem bool) (Path, error) {
} }
// Turn into a Builder to reuse code that ignores empty elements. // Turn into a Builder to reuse code that ignores empty elements.
pb, err := Builder{}.UnescapeAndAppend(split(p)...) pb, err := Builder{}.UnescapeAndAppend(Split(p)...)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, templateErrPathParsing, p) return nil, errors.Wrapf(err, templateErrPathParsing, p)
} }
@ -496,7 +496,7 @@ func join(elements []string) string {
// split takes an escaped string and returns a slice of path elements. The // split takes an escaped string and returns a slice of path elements. The
// string is split on the path separator according to the escaping rules. The // string is split on the path separator according to the escaping rules. The
// provided string must not contain an unescaped trailing path separator. // provided string must not contain an unescaped trailing path separator.
func split(segment string) []string { func Split(segment string) []string {
res := make([]string, 0) res := make([]string, 0)
numEscapes := 0 numEscapes := 0
startIdx := 0 startIdx := 0