diff options
Diffstat (limited to 'src/helpers/url-helpers.js')
-rw-r--r-- | src/helpers/url-helpers.js | 16 |
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 | |||
1 | import { URL } from 'url'; | 3 | import { URL } from 'url'; |
4 | import { ensureDirSync } from 'fs-extra'; | ||
5 | import { shell } from 'electron'; | ||
2 | 6 | ||
3 | import { ALLOWED_PROTOCOLS } from '../config'; | 7 | import { 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 | |||
26 | export 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 | ||
32 | export function openExternalUrl(url, skipValidityCheck = false) { | ||
33 | if (skipValidityCheck || isValidExternalURL(url)) { | ||
34 | shell.openExternal(url); | ||
35 | } | ||
36 | } | ||