wangchuanjin 10 місяців тому
батько
коміт
5d0e77bca6
1 змінених файлів з 8 додано та 6 видалено
  1. 8 6
      jyBXSubscribe/rpc/model/push.go

+ 8 - 6
jyBXSubscribe/rpc/model/push.go

@@ -307,13 +307,15 @@ func (s *subscribePush) subStrDetail(matchKey, detail string) string {
 		}
 		matchKeys = append(matchKeys, regexp.QuoteMeta(v))
 	}
-	indexs := regexp.MustCompile(strings.Join(matchKeys, "|")).FindStringIndex(detail)
-	if len(indexs) > 0 {
-		start := string(detail[0:indexs[0]])
-		if len([]rune(start)) > 50 {
-			start = string([]rune(start)[len([]rune(start))-50:])
+	if len(matchKeys) > 0 {
+		indexs := regexp.MustCompile(strings.Join(matchKeys, "|")).FindStringIndex(detail)
+		if len(indexs) > 0 {
+			start := string(detail[0:indexs[0]])
+			if len([]rune(start)) > 50 {
+				start = string([]rune(start)[len([]rune(start))-50:])
+			}
+			detail = start + string(detail[indexs[0]:])
 		}
-		detail = start + string(detail[indexs[0]:])
 	}
 	if len([]rune(detail)) > 200 {
 		detail = string([]rune(detail)[:200])