mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-04 00:15:28 +08:00
fix: update URL decoding method and refine file ID extraction logic to exclude text-based inputs
This commit is contained in:
@@ -292,7 +292,7 @@ func decodeDataURL(raw string, explicitContentType string) ([]byte, string, erro
|
||||
}
|
||||
return decoded, contentType, nil
|
||||
}
|
||||
decoded, err := url.QueryUnescape(payload)
|
||||
decoded, err := url.PathUnescape(payload)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
@@ -8,13 +8,24 @@ func collectOpenAIRefFileIDs(req map[string]any) []string {
|
||||
}
|
||||
out := make([]string, 0, 4)
|
||||
seen := map[string]struct{}{}
|
||||
for _, raw := range []any{
|
||||
req["ref_file_ids"],
|
||||
req["file_ids"],
|
||||
req["attachments"],
|
||||
req["messages"],
|
||||
req["input"],
|
||||
for _, key := range []string{
|
||||
"ref_file_ids",
|
||||
"file_ids",
|
||||
"attachments",
|
||||
"messages",
|
||||
"input",
|
||||
} {
|
||||
raw := req[key]
|
||||
if raw == nil {
|
||||
continue
|
||||
}
|
||||
// Skip top-level strings for 'messages' and 'input' as they are likely plain text content,
|
||||
// not file IDs. String file IDs are expected in 'ref_file_ids' or 'file_ids'.
|
||||
if key == "messages" || key == "input" {
|
||||
if _, ok := raw.(string); ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
appendOpenAIRefFileIDs(&out, seen, raw)
|
||||
}
|
||||
if len(out) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user