fix: can't search username with '-' charactor

This commit is contained in:
hgaol
2024-03-04 22:10:47 +08:00
committed by kumfo
parent bee1f5624e
commit d26079a188
+4 -3
View File
@@ -20,11 +20,12 @@
package schema
import (
"regexp"
"strings"
"github.com/apache/incubator-answer/internal/base/constant"
"github.com/apache/incubator-answer/internal/base/validator"
"github.com/apache/incubator-answer/plugin"
"regexp"
"strings"
)
type SearchDTO struct {
@@ -40,7 +41,7 @@ type SearchDTO struct {
func (s *SearchDTO) Check() (errField []*validator.FormErrorField, err error) {
// Replace special characters.
// Special characters will cause the search abnormal, such as search for "#" will get nearly all the content that Markdown format.
s.Query = regexp.MustCompile(`[+#.<>\-_()*]`).ReplaceAllString(s.Query, " ")
s.Query = regexp.MustCompile(`[+#.<>_()*]`).ReplaceAllString(s.Query, " ")
s.Query = regexp.MustCompile(`\s+`).ReplaceAllString(s.Query, " ")
s.Query = strings.TrimSpace(s.Query)
return nil, nil