fix: naming match

This commit is contained in:
Simon Ding
2024-07-16 18:58:13 +08:00
parent fb04ca03d3
commit 6bc3a6f49e
2 changed files with 14 additions and 5 deletions

View File

@@ -2,8 +2,11 @@ package utils
import (
"regexp"
"strings"
"unicode"
"github.com/adrg/strutil"
"github.com/adrg/strutil/metrics"
"golang.org/x/crypto/bcrypt"
"golang.org/x/exp/rand"
)
@@ -48,3 +51,11 @@ func RandString(n int) string {
}
return string(b)
}
func IsNameAcceptable(name1, name2 string) bool {
re := regexp.MustCompile(`[^\p{L}\w\s]`)
name1 = re.ReplaceAllString(strings.ToLower(name1), "")
name2 = re.ReplaceAllString(strings.ToLower(name2), "")
return strutil.Similarity(name1, name2, metrics.NewHamming()) > 0.1
}