Skip to content

Commit

Permalink
Merge pull request #587 from companieshouse/bug/IDVA5-1710-Start-Now-…
Browse files Browse the repository at this point in the history
…Button-Issue

Updating form action
  • Loading branch information
ttingle-ch authored Jan 20, 2025
2 parents 474c3a9 + dce88af commit 90036f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/middleware/content_security_policy_middleware_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const prepareCSPConfig = (nonce: string) : HelmetOptions => {
const SELF = `'self'`;
const NONCE = `'nonce-${nonce}'`;
const ONE_YEAR_SECONDS = 31536000;
const CHS_URL_NO_PROTOCAL = removeProtocal(CHS_URL);

return {
contentSecurityPolicy: {
Expand All @@ -15,7 +16,7 @@ export const prepareCSPConfig = (nonce: string) : HelmetOptions => {
imgSrc: [CDN_HOST],
styleSrc: [NONCE, CDN_HOST],
connectSrc: [SELF, PIWIK_URL],
formAction: [SELF, PIWIK_CHS_DOMAIN, CHS_URL],
formAction: [SELF, PIWIK_CHS_DOMAIN, CHS_URL_NO_PROTOCAL],
scriptSrc: [NONCE, CDN_HOST, PIWIK_URL],
objectSrc: [`'none'`]
}
Expand All @@ -29,3 +30,7 @@ export const prepareCSPConfig = (nonce: string) : HelmetOptions => {
}
};
};

const removeProtocal = (url: string): string => {
return url.replace(/https?:\/\//, "");
};

0 comments on commit 90036f9

Please sign in to comment.