chore: enable Trusted Types in default app (#27453)

This commit is contained in:
Milan Burda 2021-01-25 17:08:58 +01:00 committed by GitHub
parent d0c4a685fc
commit e7c201288c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -1,10 +1,15 @@
import { ipcRenderer, contextBridge } from 'electron';
const policy = window.trustedTypes.createPolicy('electron-default-app', {
// we trust the SVG contents
createHTML: input => input
});
async function getOcticonSvg (name: string) {
try {
const response = await fetch(`octicon/${name}.svg`);
const div = document.createElement('div');
div.innerHTML = await response.text();
div.innerHTML = policy.createHTML(await response.text());
return div;
} catch {
return null;