aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/url-helpers.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/helpers/url-helpers.js b/src/helpers/url-helpers.js
index 972f9b79a..b0dc9afbb 100644
--- a/src/helpers/url-helpers.js
+++ b/src/helpers/url-helpers.js
@@ -1,4 +1,8 @@
1// This is taken from: https://benjamin-altpeter.de/shell-openexternal-dangers/
2
1import { URL } from 'url'; 3import { URL } from 'url';
4import { ensureDirSync } from 'fs-extra';
5import { shell } from 'electron';
2 6
3import { ALLOWED_PROTOCOLS } from '../config'; 7import { ALLOWED_PROTOCOLS } from '../config';
4 8
@@ -18,3 +22,15 @@ export function isValidExternalURL(url) {
18 22
19 return isAllowed; 23 return isAllowed;
20} 24}
25
26export async function openPath(folderName) {
27 ensureDirSync(folderName);
28 shell.openPath(folderName);
29}
30
31// TODO: Need to verify and fix/remove the skipping logic. Ideally, we should never skip this check
32export function openExternalUrl(url, skipValidityCheck = false) {
33 if (skipValidityCheck || isValidExternalURL(url)) {
34 shell.openExternal(url);
35 }
36}