Skip to content

Commit 7e46940

Browse files
committed
Preserve POSIX paths in archive entries and query name hashes
1 parent d443a4d commit 7e46940

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/plugins/apps/src/assets.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export const collectAssets = async (patterns: string[], cwd: string): Promise<As
6060

6161
return {
6262
absolutePath: matches[index],
63-
relativePath: strippedPath,
63+
// Normalize to forward slashes so archive entries are valid
64+
// on all platforms (ZIP spec requires POSIX separators).
65+
relativePath: strippedPath.split(path.sep).join('/'),
6466
};
6567
});
6668

packages/plugins/apps/src/backend/encodeQueryName.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Copyright 2019-Present Datadog, Inc.
44

55
import { createHash } from 'crypto';
6+
import path from 'path';
67

78
import type { BackendFunction } from './discovery';
89

@@ -15,6 +16,8 @@ import type { BackendFunction } from './discovery';
1516
* proxy codegen, the production build, and the dev server.
1617
*/
1718
export function encodeQueryName(ref: Pick<BackendFunction, 'relativePath' | 'name'>): string {
18-
const pathHash = createHash('sha256').update(ref.relativePath).digest('hex');
19+
// Normalize to forward slashes so the hash is consistent across platforms.
20+
const posixPath = ref.relativePath.split(path.sep).join('/');
21+
const pathHash = createHash('sha256').update(posixPath).digest('hex');
1922
return `${pathHash}.${ref.name}`;
2023
}

packages/plugins/apps/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,18 @@ Either:
122122
const frontendOnly = assets.filter((a) => !backendPaths.has(a.absolutePath));
123123

124124
// Prefix all frontend assets with frontend/.
125+
// Use POSIX joins — archive entries must use forward slashes.
125126
const allAssets: Asset[] = frontendOnly.map((asset) => ({
126127
...asset,
127-
relativePath: path.join('frontend', asset.relativePath),
128+
relativePath: `frontend/${asset.relativePath}`,
128129
}));
129130

130131
// Append backend assets from the outputs map populated during the build.
131132
// Keys are encoded query names ({hash(path)}.{name}).
132133
for (const [bundleName, absolutePath] of backendOutputs) {
133134
allAssets.push({
134135
absolutePath,
135-
relativePath: path.join('backend', `${bundleName}.js`),
136+
relativePath: `backend/${bundleName}.js`,
136137
});
137138
}
138139

0 commit comments

Comments
 (0)