(url: string, filename?: string)
| 23 | } |
| 24 | |
| 25 | function fileName(url: string, filename?: string) { |
| 26 | if (filename) { |
| 27 | return filename |
| 28 | } |
| 29 | |
| 30 | try { |
| 31 | const next = new URL(url) |
| 32 | if (next.protocol !== "file:") { |
| 33 | return url |
| 34 | } |
| 35 | |
| 36 | const name = next.pathname.split("/").at(-1) |
| 37 | if (name) { |
| 38 | return decodeURIComponent(name) |
| 39 | } |
| 40 | } catch {} |
| 41 | |
| 42 | return url |
| 43 | } |
| 44 | |
| 45 | function fileSource( |
| 46 | part: Extract<SessionMessages[number]["parts"][number], { type: "file" }>, |