Skip to content

Commit 7c9b1f0

Browse files
code-asherAkash Satheesan
authored andcommitted
Update VS Code loader with trusted types policy
1 parent 4b418f5 commit 7c9b1f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/browser/pages/vscode.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ try {
7878
// Without the full URL VS Code will try to load file://.
7979
baseUrl: `${window.location.origin}${options.csStaticBase}/lib/vscode/out`,
8080
recordStats: true,
81+
// TODO: There don't appear to be any types for trustedTypes yet.
82+
trustedTypesPolicy: (window as any).trustedTypes?.createPolicy("amdLoader", {
83+
createScriptURL(value: string): string {
84+
if (value.startsWith(window.location.origin)) {
85+
return value
86+
}
87+
throw new Error(`Invalid script url: ${value}`)
88+
},
89+
}),
8190
paths: {
8291
"vscode-textmate": `../node_modules/vscode-textmate/release/main`,
8392
"vscode-oniguruma": `../node_modules/vscode-oniguruma/release/main`,
@@ -93,6 +102,7 @@ try {
93102
}
94103
} catch (error) {
95104
console.error(error)
105+
/* Probably fine. */
96106
}
97107

98108
try {

0 commit comments

Comments
 (0)