diff --git a/pkg/utils/template/helpers.go b/pkg/utils/template/helpers.go index 0d5c21c..83dc8a8 100644 --- a/pkg/utils/template/helpers.go +++ b/pkg/utils/template/helpers.go @@ -61,6 +61,9 @@ func DefaultNamifier(sentence string) string { // Remove leading numbers re = regexp.MustCompile("^[0-9]+") sentence = string(re.ReplaceAll([]byte(sentence), []byte(""))) + if len(sentence) == 0 { + return sentence + } // Upper first letter sentence = strings.ToUpper(sentence[:1]) + sentence[1:] diff --git a/pkg/utils/template/helpers_test.go b/pkg/utils/template/helpers_test.go index 93aef48..85d7d9a 100644 --- a/pkg/utils/template/helpers_test.go +++ b/pkg/utils/template/helpers_test.go @@ -22,6 +22,10 @@ type namifyCases struct { var namifyBaseCases = []namifyCases{ // Nothing {In: "", Out: ""}, + // new line + {In: "\n", Out: ""}, + // just numbers + {In: "00", Out: ""}, // Remove leading digits {In: "0name0", Out: "Name0"}, // Remove non alphanumerics