diff --git a/.changeset/angry-planes-visit.md b/.changeset/angry-planes-visit.md new file mode 100644 index 0000000000..622a7750f9 --- /dev/null +++ b/.changeset/angry-planes-visit.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-common': patch +--- + +Disable stripping of ZIP archive diff --git a/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts b/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts index 5c12a383ee..c40557ce94 100644 --- a/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts +++ b/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts @@ -38,6 +38,7 @@ export class ZipArchiveResponse implements ReadTreeResponse { private readonly workDir: string, public readonly etag: string, private readonly filter?: (path: string, info: { size: number }) => boolean, + private readonly stripFirstDirectoryFromPath?: boolean, ) { if (subPath) { if (!subPath.endsWith('/')) { @@ -67,7 +68,7 @@ export class ZipArchiveResponse implements ReadTreeResponse { } private shouldBeIncluded(entry: Entry): boolean { - const strippedPath = stripFirstDirectoryFromPath(entry.path); + const strippedPath = this.stripFirstDirectoryFromPath ? stripFirstDirectoryFromPath(entry.path) : entry.path; if (this.subPath) { if (!strippedPath.startsWith(this.subPath)) { @@ -99,7 +100,7 @@ export class ZipArchiveResponse implements ReadTreeResponse { if (this.shouldBeIncluded(entry)) { files.push({ - path: this.getInnerPath(stripFirstDirectoryFromPath(entry.path)), + path: this.getInnerPath(this.stripFirstDirectoryFromPath ? stripFirstDirectoryFromPath(entry.path) : entry.path), content: () => entry.buffer(), }); } else { @@ -148,7 +149,7 @@ export class ZipArchiveResponse implements ReadTreeResponse { // as a zip can have files with directories without directory entries if (entry.type === 'File' && this.shouldBeIncluded(entry)) { const entryPath = this.getInnerPath( - stripFirstDirectoryFromPath(entry.path), + this.stripFirstDirectoryFromPath ? stripFirstDirectoryFromPath(entry.path) : entry.path, ); const dirname = platformPath.dirname(entryPath); if (dirname) {