Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
fix an instance of an empty claim name
Browse files Browse the repository at this point in the history
  • Loading branch information
nikooo777 committed Jan 3, 2024
1 parent b382f33 commit 5db834c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions namer/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"sync"
)

var claimNameRegexp = regexp.MustCompile(`[=&#:$@*%??;、\\"/<>%{}||^~\x60[\]\s]`)
var claimNameRegexp = regexp.MustCompile(`[=&#:$@*%??;、\\"/<>%{}||^~\x60[\]\s]`)

type Namer struct {
mu *sync.Mutex
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions namer/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 5db834c

Please sign in to comment.