diff --git a/.gitignore b/.gitignore index 0c2a0b48..53a1f625 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ yq*.snap test.yml test*.yml +test*.yaml 0.yml 1.yml 2.yml diff --git a/acceptance_tests/split-printer.sh b/acceptance_tests/split-printer.sh index a8e81a91..4629c496 100755 --- a/acceptance_tests/split-printer.sh +++ b/acceptance_tests/split-printer.sh @@ -25,6 +25,31 @@ EOM assertEquals "$expectedDoc2" "$doc2" } +testBasicSplitWithNameCustomExtension() { + rm test*.yaml || true + cat >test.yml <test.yml < 0 { name = result.MatchingNodes.Front().Value.(*CandidateNode).Node.Value } - name = fmt.Sprintf("%v.%v", name, sp.extension) + var extensionRegexp = regexp.MustCompile(`\.[a-zA-Z0-9]+$`) + if !extensionRegexp.MatchString(name) { + name = fmt.Sprintf("%v.%v", name, sp.extension) + } f, err := os.Create(name)