(absWorkspace: string, relPath: string)
| 267 | } |
| 268 | |
| 269 | async function readPreviewSource(absWorkspace: string, relPath: string): Promise<string> { |
| 270 | let source: string; |
| 271 | try { |
| 272 | source = await readFile(await resolveSafeWorkspaceChildPath(absWorkspace, relPath), 'utf8'); |
| 273 | } catch (err) { |
| 274 | throw new Error(`read failed: ${err instanceof Error ? err.message : String(err)}`); |
| 275 | } |
| 276 | if (source.indexOf('\u0000') !== -1) { |
| 277 | throw new Error(`binary file cannot be previewed: ${relPath}`); |
| 278 | } |
| 279 | return source; |
| 280 | } |
| 281 | |
| 282 | export async function isPreviewFileUrlAllowed( |
| 283 | rawUrl: string, |
no test coverage detected