diff --git a/cmd/setupgh.go b/cmd/setupgh.go index 5a4e4d75..44f16ccd 100644 --- a/cmd/setupgh.go +++ b/cmd/setupgh.go @@ -176,15 +176,15 @@ func toValidAppName(name string) (string, error) { // remove all characters except alphanumeric, '-', '.' var builder strings.Builder for _, r := range cleanedName { - if unicode.IsLetter(r) || unicode.IsNumber(r) || r == '-' || r == '.' { + if unicode.IsLetter(r) || unicode.IsNumber(r) || r == '-' { builder.WriteRune(r) } } // lowercase the name cleanedName = strings.ToLower(builder.String()) - if ValidateAppName(cleanedName) != nil { - return "", fmt.Errorf("app name '%s' could not be converted to a valid name", name) + if err := ValidateAppName(cleanedName);err != nil { + return "", fmt.Errorf("app name '%s' could not be converted to a valid name: %w", name, err) } return cleanedName, nil } diff --git a/cmd/setupgh_test.go b/cmd/setupgh_test.go index ae194c6f..d049ae4e 100644 --- a/cmd/setupgh_test.go +++ b/cmd/setupgh_test.go @@ -67,9 +67,13 @@ func TestToValidAppName(t *testing.T) { shouldError: true, }, { - testCaseName: "dots and hypens allowed in the middle", - nameInput: "name.-.name", - expected: "name.-.name", + testCaseName: "hypens allowed in the middle", + nameInput: "name-name-name-name", + expected: "name-name-name-name", + }, { + testCaseName: "remove dots in the middle", + nameInput: "name.name-name-name", + expected: "namename-name-name", }, { testCaseName: "no capital letters", @@ -85,6 +89,9 @@ func TestToValidAppName(t *testing.T) { assert.Error(t, err) } else { assert.Equal(t, tc.expected, result) + if err != nil { + t.Errorf("expected no error, got %s", err) + } } }) }