MCPcopy Create free account
hub / github.com/0PandaDEV/Ziit / assertSafeFileId

Function assertSafeFileId

server/api/import/index.post.ts:299–307  ·  view source on GitHub ↗
(fileId: unknown)

Source from the content-addressed store, hash-verified

297const FILE_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
298
299function assertSafeFileId(fileId: unknown): void {
300 if (typeof fileId !== "string" || !FILE_ID_PATTERN.test(fileId)) {
301 throw handleApiError(
302 400,
303 `Rejected import with invalid fileId: ${JSON.stringify(fileId)}`,
304 "Invalid upload identifier.",
305 );
306 }
307}
308
309function assertWithinUserDir(userTempDir: string, targetPath: string): void {
310 const base = path.resolve(userTempDir);

Callers 2

handleChunkUploadFunction · 0.85
processFileInBackgroundFunction · 0.85

Calls 1

handleApiErrorFunction · 0.90

Tested by

no test coverage detected