Skip to content

Commit

Permalink
Loading custom script from blob
Browse files Browse the repository at this point in the history
  • Loading branch information
pbochynski committed Dec 12, 2024
1 parent 09205ea commit 7e0cb9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<meta name="theme-color" content="#000000" />
<meta
http-equiv="Content-Security-Policy"
content="font-src 'self' https://sdk.openui5.org/; script-src 'self'; object-src 'self';"
content="font-src 'self' https://sdk.openui5.org/; script-src 'self' blob:; object-src 'self';"
/>
<title>Busola</title>
</head>
Expand Down
12 changes: 11 additions & 1 deletion src/components/Extensibility/ExtensibilityList.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,17 @@ const ExtensibilityList = ({ overrideResMetadata, ...props }) => {
) {
const script = document.createElement('script');
script.type = 'module';
script.textContent = customScript;
const scriptBlob = new Blob([customScript], {
type: 'application/javascript',
});
const blobURL = URL.createObjectURL(scriptBlob);
script.src = blobURL;

// Clean up the Blob URL after the script loads
script.onload = () => {
URL.revokeObjectURL(blobURL);
};

script.onerror = e => {
console.error('Script loading or execution error:', e);
};
Expand Down

0 comments on commit 7e0cb9a

Please sign in to comment.