| 45 | } |
| 46 | |
| 47 | const resolveHttpFileUrl = (value: unknown): string => { |
| 48 | const fileUrl = typeof value === 'string' ? value.trim() : '' |
| 49 | if (!fileUrl) { |
| 50 | throw new Error('File URL is required') |
| 51 | } |
| 52 | |
| 53 | let parsed: URL |
| 54 | try { |
| 55 | parsed = new URL(fileUrl) |
| 56 | } catch { |
| 57 | throw new Error('File URL must be a valid http or https URL') |
| 58 | } |
| 59 | |
| 60 | if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { |
| 61 | throw new Error('File URL must use http or https') |
| 62 | } |
| 63 | |
| 64 | return fileUrl |
| 65 | } |
| 66 | |
| 67 | export const FileBlock: BlockConfig<FileParserOutput> = { |
| 68 | type: 'file', |