Skip to content

Commit 1408ea1

Browse files
committed
Clean up headers automation and fix delimiter formatting
1 parent 43fca35 commit 1408ea1

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

bin/generate-headers.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,26 @@ function generateHeaders(config: { paths: PathConfig[] }): string {
3838
header,
3939
value,
4040
] of Object.entries(pathConfig.headers)) {
41-
if (typeof value === 'object' && !Array.isArray(value)) {
42-
// CSP-style header with directives
41+
// Handle Content-Security-Policy (nested object)
42+
if (header === 'Content-Security-Policy') {
43+
const csp = value as Record<string, string[]>;
4344
const directives: string[] = [];
45+
4446
for (const [
4547
directive,
4648
sources,
47-
] of Object.entries(value)) {
49+
] of Object.entries(csp)) {
4850
directives.push(`${directive} ${sources.join(' ')}`);
4951
}
50-
output += ` ${header}: ${directives.join('; ')}\n`;
51-
} else {
52-
// Simple array-based header
53-
output += ` ${header}: ${value.join(' ')}\n`;
52+
53+
output += ` Content-Security-Policy: ${directives.join('; ')}\n`;
54+
continue;
5455
}
56+
57+
// Handle all other headers (arrays)
58+
const values = value as string[];
59+
const separator = header === 'Permissions-Policy' ? ', ' : '; ';
60+
output += ` ${header}: ${values.join(separator)}\n`;
5561
}
5662
}
5763

0 commit comments

Comments
 (0)