mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-07 01:50:47 +08:00
fix: naming match
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user