(fileSpecs: string[])
| 720 | * @returns Parsed file attachments |
| 721 | */ |
| 722 | export function parseFileSpecs(fileSpecs: string[]): File[] { |
| 723 | const files: File[] = [] |
| 724 | |
| 725 | // Sandbox-gateway may pass multiple specs as a single space-separated string |
| 726 | const expandedSpecs = fileSpecs.flatMap(s => s.split(' ').filter(Boolean)) |
| 727 | |
| 728 | for (const spec of expandedSpecs) { |
| 729 | const colonIndex = spec.indexOf(':') |
| 730 | if (colonIndex === -1) { |
| 731 | continue |
| 732 | } |
| 733 | |
| 734 | const fileId = spec.substring(0, colonIndex) |
| 735 | const relativePath = spec.substring(colonIndex + 1) |
| 736 | |
| 737 | if (!fileId || !relativePath) { |
| 738 | logDebugError( |
| 739 | `Invalid file spec: ${spec}. Both file_id and path are required`, |
| 740 | ) |
| 741 | continue |
| 742 | } |
| 743 | |
| 744 | files.push({ fileId, relativePath }) |
| 745 | } |
| 746 | |
| 747 | return files |
| 748 | } |
| 749 |
no test coverage detected