Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for allowed urls to be opened using shell.openExternal 🩹 #14

Merged
merged 1 commit into from Mar 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
fix: check for allowed urls to be opened using shell.openExternal 🩹
  • Loading branch information
Akash Rajpurohit committed Mar 10, 2021
commit 28f1492a12234cf1e6af85c78bf22ee2f5090d19
6 changes: 5 additions & 1 deletion preload.js
Expand Up @@ -2,6 +2,10 @@
// It has the same sandbox as a Chrome extension.
const { remote, ipcRenderer } = require('electron');

const allowedUrls = ['https://akashrajpurohit.com'];

const isValidUrl = url => allowedUrls.includes(url);

const init = () => {
window.checkClipboard = () => {
return remote.clipboard.readText();
Expand All @@ -12,7 +16,7 @@ const init = () => {
};

window.openExternalUrl = (url) => {
remote.shell.openExternal(url);
if (isValidUrl(url)) remote.shell.openExternal(url);
};

window.clearClipboard = () => {
Expand Down