fix: regex repeat compile

This commit is contained in:
Seefs
2025-12-03 00:41:47 +08:00
parent 7d1bad1b37
commit 896e4ac671
5 changed files with 23 additions and 18 deletions

View File

@@ -23,11 +23,11 @@ func Marshal(v any) ([]byte, error) {
}
func GetJsonType(data json.RawMessage) string {
data = bytes.TrimSpace(data)
if len(data) == 0 {
trimmed := bytes.TrimSpace(data)
if len(trimmed) == 0 {
return "unknown"
}
firstChar := bytes.TrimSpace(data)[0]
firstChar := trimmed[0]
switch firstChar {
case '{':
return "object"