MCPcopy Index your code
hub / github.com/massCodeIO/massCode / expandZipFiles

Function expandZipFiles

src/main/http/import/zip.ts:13–49  ·  view source on GitHub ↗
(
  files: HttpImportFile[],
)

Source from the content-addressed store, hash-verified

11}
12
13export async function expandZipFiles(
14 files: HttpImportFile[],
15): Promise<HttpImportFile[]> {
16 const expandedFiles: HttpImportFile[] = []
17
18 for (const file of files) {
19 if (!isZipFile(file)) {
20 expandedFiles.push(file)
21 continue
22 }
23
24 const zip = await JSZip.loadAsync(
25 file.encoding === 'base64' ? decodeBase64(file.content) : file.content,
26 )
27
28 for (const [path, entry] of Object.entries(zip.files)) {
29 if (entry.dir)
30 continue
31
32 const lowerPath = path.toLowerCase()
33 if (
34 !lowerPath.endsWith('.yml')
35 && !lowerPath.endsWith('.yaml')
36 && !lowerPath.endsWith('.json')
37 ) {
38 continue
39 }
40
41 expandedFiles.push({
42 content: await entry.async('string'),
43 name: `${file.name}/${path}`,
44 })
45 }
46 }
47
48 return expandedFiles
49}

Callers 2

parseHttpImportFilesFunction · 0.90

Calls 2

isZipFileFunction · 0.85
decodeBase64Function · 0.85

Tested by

no test coverage detected