Skip to content

Commit

Permalink
fix: to inject app env script as one liner (#3494)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko authored Apr 15, 2024
1 parent b3c26dd commit 6a7900d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-squids-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/mc-html-template': patch
---

Ensure injected application environment script is rendered as one liner (to match the CSP hash)
4 changes: 1 addition & 3 deletions packages/mc-html-template/html-docs/application.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@
__LOADING_SCREEN_JS__

<!-- Application globals -->
<script>
window.app = __APPLICATION_ENVIRONMENT__;
</script>
__APPLICATION_ENVIRONMENT__

<!-- Main application chunks -->
__APPLICATION_SCRIPT_IMPORTS__
Expand Down
2 changes: 1 addition & 1 deletion packages/mc-html-template/src/replace-html-placeholders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const replaceHtmlPlaceholders = (
)
.replace(
new RegExp('__APPLICATION_ENVIRONMENT__', 'g'),
sanitizeAppEnvironment(options.env)
`<script>window.app = ${sanitizeAppEnvironment(options.env)};</script>`
)
.replace(
new RegExp('__LOADING_SCREEN_JS__', 'g'),
Expand Down

0 comments on commit 6a7900d

Please sign in to comment.