File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments