File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -99,4 +99,10 @@ describe("CSP Builder", () => {
9999 const expectBuilder = new CspBuilder ( ) . withStrictDynamic ( hashes ) ;
100100 expect ( expectBuilder . csp ( ) ) . toEqual ( fixtureBuilder . csp ( ) ) ;
101101 } ) ;
102+
103+ it ( "can quotes script in require-trusted-types-for correctly" , ( ) => {
104+ const fixtureBuilder = new CspBuilder ( `require-trusted-types-for 'script';` ) ;
105+ const expectBuilder = new CspBuilder ( ) . withDirectives ( { "require-trusted-types-for" : [ "script" ] } ) ;
106+ expect ( expectBuilder . toString ( ) ) . toEqual ( fixtureBuilder . toString ( ) ) ;
107+ } ) ;
102108} ) ;
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export class CspBuilder {
4141 const isCspHeader = param [ 0 ] === CSP_HEADER ;
4242 const isCspReportOnlyHeader = param [ 0 ] === CSP_HEADER_REPORT_ONLY ;
4343 if ( ! ( isCspHeader || isCspReportOnlyHeader ) ) {
44- this . _csp = empty ;
44+ this . _csp = { ... empty } ;
4545 } else {
4646 this . _csp = {
4747 directives : fromCspContent ( param [ 1 ] ) ,
@@ -58,7 +58,7 @@ export class CspBuilder {
5858 } ;
5959 }
6060 } else {
61- this . _csp = empty ;
61+ this . _csp = { ... empty } ;
6262 }
6363 }
6464
@@ -212,7 +212,7 @@ export class CspBuilder {
212212 }
213213
214214 public reset ( ) {
215- this . _csp = empty ;
215+ this . _csp = { ... empty } ;
216216 }
217217
218218 public isEmpty ( ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const singleQuotify = (directiveValue: string) => `'${directiveValue}'`;
1919
2020const isLiteralDirectiveValue = ( directiveValue : string ) => {
2121 const c1 = [
22+ "script" ,
2223 "strict-dynamic" ,
2324 "report-sample" ,
2425 "self" ,
You can’t perform that action at this time.
0 commit comments