Skip to content

Commit 6df356f

Browse files
committed
add --trusted-types flag to yarn web
1 parent 7fc71f6 commit 6df356f

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

resources/web/code-web.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const args = minimist(process.argv, {
3636
'help',
3737
'verbose',
3838
'wrap-iframe',
39-
'enable-sync'
39+
'enable-sync',
40+
'trusted-types'
4041
],
4142
string: [
4243
'scheme',
@@ -53,6 +54,7 @@ if (args.help) {
5354
'yarn web [options]\n' +
5455
' --no-launch Do not open VSCode web in the browser\n' +
5556
' --wrap-iframe Wrap the Web Worker Extension Host in an iframe\n' +
57+
' --trusted-types Enable trusted types (report only)\n' +
5658
' --enable-sync Enable sync by default\n' +
5759
' --scheme Protocol (https or http)\n' +
5860
' --host Remote host\n' +
@@ -396,7 +398,13 @@ async function handleRoot(req, res) {
396398
.replace('{{WEBVIEW_ENDPOINT}}', '')
397399
.replace('{{REMOTE_USER_DATA_URI}}', '');
398400

399-
res.writeHead(200, { 'Content-Type': 'text/html' });
401+
402+
const headers = { 'Content-Type': 'text/html' };
403+
if (args['trusted-types']) {
404+
headers['Content-Security-Policy-Report-Only'] = 'require-trusted-types-for \'script\';';
405+
}
406+
407+
res.writeHead(200, headers);
400408
return res.end(data);
401409
}
402410

0 commit comments

Comments
 (0)