MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / readPreviewSource

Function readPreviewSource

apps/desktop/src/main/preview-runtime.ts:269–280  ·  view source on GitHub ↗
(absWorkspace: string, relPath: string)

Source from the content-addressed store, hash-verified

267}
268
269async 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
282export async function isPreviewFileUrlAllowed(
283 rawUrl: string,

Callers 1

runPreviewFunction · 0.85

Calls 1

Tested by

no test coverage detected