Skip to content

Commit fd24d7a

Browse files
authored
feat: Optimize add key support for more strings (#347)
1 parent e4685a8 commit fd24d7a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

internal/services/key_service.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (s *KeyService) ParseKeysFromText(text string) []string {
168168
}
169169

170170
// 通用解析:通过分隔符分割文本,不使用复杂的正则表达式
171-
delimiters := regexp.MustCompile(`[\s,;|\n\r\t]+`)
171+
delimiters := regexp.MustCompile(`[\s,;\n\r\t]+`)
172172
splitKeys := delimiters.Split(strings.TrimSpace(text), -1)
173173

174174
for _, key := range splitKeys {
@@ -195,13 +195,7 @@ func (s *KeyService) filterValidKeys(keys []string) []string {
195195

196196
// isValidKeyFormat performs basic validation on key format
197197
func (s *KeyService) isValidKeyFormat(key string) bool {
198-
if key == "" ||
199-
strings.TrimSpace(key) == "" {
200-
return false
201-
}
202-
203-
validChars := regexp.MustCompile(`^[a-zA-Z0-9_\-./+=:]+$`)
204-
return validChars.MatchString(key)
198+
return strings.TrimSpace(key) != ""
205199
}
206200

207201
// RestoreMultipleKeys handles the business logic of restoring keys from a text block.

0 commit comments

Comments
 (0)