diff --git a/namer/names.go b/namer/names.go index 240aec8..4d00f00 100644 --- a/namer/names.go +++ b/namer/names.go @@ -10,7 +10,7 @@ import ( "sync" ) -var claimNameRegexp = regexp.MustCompile(`[=&#:$@*%??;、\\"/<>%{}||^~\x60[\]\s]`) +var claimNameRegexp = regexp.MustCompile(`[ =&#:$@*%??;、\\"/<>%{}||^~\x60[\]\s]`) type Namer struct { mu *sync.Mutex @@ -42,7 +42,7 @@ func (n *Namer) GetNextName(prefix string) string { attempt++ } - //if for some reasons the title can't be converted in a valid claim name (too short or not latin) then we use a hash + //if for some reason the title can't be converted in a valid claim name (too short or not latin) then we use a hash attempt = 1 if len(name) < 2 { sum := md5.Sum([]byte(prefix)) diff --git a/namer/names_test.go b/namer/names_test.go index 6b023bb..4263393 100644 --- a/namer/names_test.go +++ b/namer/names_test.go @@ -29,4 +29,6 @@ func Test_getClaimNameFromTitle(t *testing.T) { assert.Equal(t, "wtf-aaa", name) name = getClaimNameFromTitle("wtf-*aaa", 0) assert.Equal(t, "wtf-aaa", name) + name = getClaimNameFromTitle(" ", 0) + assert.Equal(t, "", name) }