Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Fix HTML injection; fix Raven
Browse files Browse the repository at this point in the history
Had to make the Raven installation stuff its own script so it wouldn't
run before raven.js was loaded.

Also fixed my Regexps for HTML injection; they didn't work so well when
the HTML was minified.
  • Loading branch information
mxstbr committed Oct 13, 2017
1 parent 9d88392 commit 5ee0b0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions iris/renderer/get-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import serialize from 'serialize-javascript';
const html = fs
.readFileSync(path.resolve(__dirname, '..', '..', 'build', 'index.html'))
.toString()
.replace(/<script.+?bootstrap\.js\".+?<\/script>/, '')
.replace(/(<script)(.+?bundle.+?<\/script>)/, '$1 defer="defer" $2');
.replace(
'<script type="text/javascript" src="/./static/js/bootstrap.js">',
''
)
.replace(/(src="\/static\/js\/main\.\w+?\.js")/g, ' defer="defer" $1');

type Arguments = {
styleTags: string,
Expand All @@ -20,7 +23,7 @@ type Arguments = {
export const createScriptTag = ({ src }: { src: string }) =>
`<script defer="defer" src="${src}"></script>`;

const sentry = `<script defer="defer" src="https://cdn.ravenjs.com/3.14.0/raven.min.js" crossorigin="anonymous"></script><script>Raven.config('https://[email protected]/154812', { whitelistUrls: [/spectrum.chat/, /www.spectrum.chat/] }).install();</script>`;
const sentry = `<script defer="defer" src="https://cdn.ravenjs.com/3.14.0/raven.min.js" crossorigin="anonymous"></script><script defer="defer" src="/install-raven.js"></script>`;

export const getHTML = ({
styleTags,
Expand Down
3 changes: 3 additions & 0 deletions public/install-raven.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Raven.config('https://[email protected]/154812', {
whitelistUrls: [/spectrum.chat/, /www.spectrum.chat/],
}).install();

0 comments on commit 5ee0b0b

Please sign in to comment.