docs(docs-infra): Remove leading path from zipped files. (#59726)

In certain circonstances, a leading slash in the file paths created a incorrect unarchived project.

fixes #57075

PR Close #59726
This commit is contained in:
Matthieu Riegler 2025-01-26 11:15:17 -08:00 committed by Pawel Kozlowski
parent ccebbbae6e
commit 97897eebd8

View file

@ -14,6 +14,9 @@ import {zip, strToU8} from 'fflate';
export async function generateZip(files: FileAndContent[]): Promise<Uint8Array> {
const filesObj: Record<string, Uint8Array> = {};
files.forEach(({path, content}) => {
if (path.startsWith('/')) {
path = path.slice(1);
}
filesObj[path] = typeof content === 'string' ? strToU8(content) : content;
});