INNER CODE UNIT · TypeScript
resolveMember
software-mansion/argent · packages/archive/src/index.ts:135
async function resolveMember(destDir: string, expectedName: string): Promise<string> {
const entries = await readdir(destDir);
if (entries.includes(expectedName)) {
return join(destDir, expectedName);
}
const real = entries.filter((e) => !e.startsWith("._"));
if (real.length !== 1) {
throw new ArchiveError(
`Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
);
}
return join(destDir, real[0]!);
}
/**
* Vet a gzipped tar (no path or symlink escaping `destDir`), extract it into
* `destDir`, and return its top-level member path. Used in both directions —
* neither the uploading client nor the serving tool-server is trusted. Throws