aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/url-helpers.ts
diff options
context:
space:
mode:
authorLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2021-10-26 08:57:50 +0530
committerLibravatar GitHub <noreply@github.com>2021-10-26 08:57:50 +0530
commit2edcf95e6cf390e4511e3bfd61cdab6057cd6adc (patch)
treeb85c62fb608612f23c178c8d19f9598e2b48fe8b /src/helpers/url-helpers.ts
parentdocs: added 'sreelekhaMarasig' as contributor for code [skip ci] (diff)
downloadferdium-app-2edcf95e6cf390e4511e3bfd61cdab6057cd6adc.tar.gz
ferdium-app-2edcf95e6cf390e4511e3bfd61cdab6057cd6adc.tar.zst
ferdium-app-2edcf95e6cf390e4511e3bfd61cdab6057cd6adc.zip
feature: allow 'file' urls for services (fixes #2118) (#2130)
Diffstat (limited to 'src/helpers/url-helpers.ts')
-rw-r--r--src/helpers/url-helpers.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/helpers/url-helpers.ts b/src/helpers/url-helpers.ts
index 135f06cbf..c1ca3ab25 100644
--- a/src/helpers/url-helpers.ts
+++ b/src/helpers/url-helpers.ts
@@ -1,7 +1,7 @@
1// This is taken from: https://benjamin-altpeter.de/shell-openexternal-dangers/ 1// This is taken from: https://benjamin-altpeter.de/shell-openexternal-dangers/
2 2
3import { URL } from 'url'; 3import { URL } from 'url';
4import { ensureDirSync } from 'fs-extra'; 4import { ensureDirSync, existsSync } from 'fs-extra';
5import { shell } from 'electron'; 5import { shell } from 'electron';
6 6
7import { ALLOWED_PROTOCOLS } from '../config'; 7import { ALLOWED_PROTOCOLS } from '../config';
@@ -23,6 +23,10 @@ export function isValidExternalURL(url: string | URL) {
23 return isAllowed; 23 return isAllowed;
24} 24}
25 25
26export function isValidFileUrl(path: string) {
27 return path.startsWith('file') && existsSync(new URL(path));
28}
29
26export async function openPath(folderName: string) { 30export async function openPath(folderName: string) {
27 ensureDirSync(folderName); 31 ensureDirSync(folderName);
28 shell.openPath(folderName); 32 shell.openPath(folderName);