* Whether a file's key is usable at run time: an explicit non-empty `key`, or an * internal `/api/files/serve/...` URL the key can actually be parsed from. This * mirrors `normalizeStartFile` exactly (including the parse, so a malformed * internal URL is rejected rather than accepted on the prefi
(file: InputFormatFile)
| 69 | * internal URL is rejected rather than accepted on the prefix alone). |
| 70 | */ |
| 71 | function hasRecoverableFileKey(file: InputFormatFile): boolean { |
| 72 | if (typeof file.key === 'string' && file.key.length > 0) return true |
| 73 | if (typeof file.url !== 'string' || !isInternalFileUrl(file.url)) return false |
| 74 | try { |
| 75 | return parseInternalFileUrl(file.url).key.length > 0 |
| 76 | } catch { |
| 77 | return false |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Tolerantly parses a file field's stored value (a JSON string, or an already |
no test coverage detected