mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
feat: Allow paths starting with slash
This commit is contained in:
@@ -11,6 +11,13 @@ import "strings"
|
||||
func PathSplitter(path string, delimiter string) []string {
|
||||
ps := strings.Split(path, delimiter)
|
||||
var res []string
|
||||
|
||||
// allow path to start with forward slash
|
||||
// i.e. /a/b/c
|
||||
if len(ps) > 1 && ps[0] == "" {
|
||||
ps = ps[1:]
|
||||
}
|
||||
|
||||
res = append(res, ps[0])
|
||||
for i := 1; i < len(ps); i++ {
|
||||
last := len(res) - 1
|
||||
|
||||
@@ -27,6 +27,10 @@ func TestPathSplitter(t *testing.T) {
|
||||
path: "a/b/c",
|
||||
exp: []string{"a", "b", "c"},
|
||||
},
|
||||
{
|
||||
path: "/a/b/c",
|
||||
exp: []string{"a", "b", "c"},
|
||||
},
|
||||
{
|
||||
path: `a/b[]/c`,
|
||||
exp: []string{"a", "b[]", "c"},
|
||||
|
||||
Reference in New Issue
Block a user