aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/asar-helpers.js3
-rw-r--r--src/helpers/i18n-helpers.js27
-rw-r--r--src/helpers/url-helpers.js15
3 files changed, 37 insertions, 8 deletions
diff --git a/src/helpers/asar-helpers.js b/src/helpers/asar-helpers.js
new file mode 100644
index 000000000..9e4380c06
--- /dev/null
+++ b/src/helpers/asar-helpers.js
@@ -0,0 +1,3 @@
1export function asarPath(dir = '') {
2 return dir.replace('app.asar', 'app.asar.unpacked');
3}
diff --git a/src/helpers/i18n-helpers.js b/src/helpers/i18n-helpers.js
index 091b86b06..84146dd8c 100644
--- a/src/helpers/i18n-helpers.js
+++ b/src/helpers/i18n-helpers.js
@@ -28,22 +28,33 @@ export function getLocale({
28 return localeStr; 28 return localeStr;
29} 29}
30 30
31export function getSelectOptions({ locales, resetToDefaultText = '' }) { 31export function getSelectOptions({ locales, resetToDefaultText = '', automaticDetectionText = '' }) {
32 let options = []; 32 const options = [];
33 33
34 if (resetToDefaultText) { 34 if (resetToDefaultText) {
35 options = [ 35 options.push(
36 { 36 {
37 value: '', 37 value: '',
38 label: resetToDefaultText, 38 label: resetToDefaultText,
39 }, {
40 value: '───',
41 label: '───',
42 disabled: true,
43 }, 39 },
44 ]; 40 );
45 } 41 }
46 42
43 if (automaticDetectionText) {
44 options.push(
45 {
46 value: 'automatic',
47 label: automaticDetectionText,
48 },
49 );
50 }
51
52 options.push({
53 value: '───',
54 label: '───',
55 disabled: true,
56 });
57
47 Object.keys(locales).sort(Intl.Collator().compare).forEach((key) => { 58 Object.keys(locales).sort(Intl.Collator().compare).forEach((key) => {
48 options.push({ 59 options.push({
49 value: key, 60 value: key,
diff --git a/src/helpers/url-helpers.js b/src/helpers/url-helpers.js
new file mode 100644
index 000000000..750d1f00c
--- /dev/null
+++ b/src/helpers/url-helpers.js
@@ -0,0 +1,15 @@
1import { URL } from 'url';
2
3import { ALLOWED_PROTOCOLS } from '../config';
4
5const debug = require('debug')('Franz:Helpers:url');
6
7export function isValidExternalURL(url) {
8 const parsedUrl = new URL(url);
9
10 const isAllowed = ALLOWED_PROTOCOLS.includes(parsedUrl.protocol);
11
12 debug('protocol check is', isAllowed, 'for:', url);
13
14 return isAllowed;
15}