When split expression includes an extension, dont add .yml automatically

This commit is contained in:
Mike Farah
2022-06-23 14:31:09 +10:00
parent f63d76f006
commit dfd396b480
3 changed files with 31 additions and 1 deletions
+5 -1
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"os"
"regexp"
"gopkg.in/yaml.v3"
)
@@ -67,7 +68,10 @@ func (sp *multiPrintWriter) GetWriter(node *CandidateNode) (*bufio.Writer, error
if result.MatchingNodes.Len() > 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)