MCPcopy Create free account
hub / github.com/experdot/pointer / resolveDirectoryWithinAttachmentsRoot

Function resolveDirectoryWithinAttachmentsRoot

src/main/attachmentStorage.ts:69–81  ·  view source on GitHub ↗
(...segments: string[])

Source from the content-addressed store, hash-verified

67}
68
69function resolveDirectoryWithinAttachmentsRoot(...segments: string[]): string {
70 const attachmentsRoot = getCurrentAttachmentsDirectory()
71 const resolvedPath = path.resolve(
72 attachmentsRoot,
73 ...segments.map((segment) => validatePathSegment(segment, 'path segment'))
74 )
75
76 if (!isPathWithinRoot(resolvedPath, attachmentsRoot)) {
77 throw new Error('Resolved path escapes attachments root')
78 }
79
80 return resolvedPath
81}
82
83export async function saveAttachmentFile(options: {
84 fileId: string

Callers 3

Calls 3

isPathWithinRootFunction · 0.90
validatePathSegmentFunction · 0.85

Tested by

no test coverage detected