TrimBlankChar添加对于隐藏字符的过滤
This commit is contained in:
@@ -242,7 +242,7 @@ func FilterEmoji(content string) string {
|
||||
}
|
||||
|
||||
func TrimBlankChar(str string) string {
|
||||
return strings.Trim(str, "\n\r\t ")
|
||||
return strings.Trim(str, "\u202C\n\r\t ")
|
||||
}
|
||||
|
||||
func RemoveGeneralMapKeys(obj map[string]interface{}, keys ...string) map[string]interface{} {
|
||||
|
||||
@@ -191,11 +191,22 @@ func TestRemoveGeneralMapKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTrimBlanChar(t *testing.T) {
|
||||
str := `
|
||||
for _, strList := range [][]string{
|
||||
[]string{
|
||||
"大小21",
|
||||
`
|
||||
大小21
|
||||
`
|
||||
if TrimBlankChar(str) != "大小21" {
|
||||
t.Fatal("TrimBlanChar doesn't work")
|
||||
`,
|
||||
},
|
||||
[]string{
|
||||
"13518183468",
|
||||
"13518183468", // 末尾有一个隐藏字符
|
||||
},
|
||||
} {
|
||||
t.Logf("%d,%d", len(strList[0]), len(strList[1]))
|
||||
if TrimBlankChar(strList[1]) != strList[0] {
|
||||
t.Fatal("TrimBlanChar doesn't work")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user