aboutsummaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-07 12:25:00 +0100
committerLibravatar GitHub <noreply@github.com>2017-11-07 12:25:00 +0100
commitc55885e69e195e4413fda3bffffafeaee7c0c9d5 (patch)
treeb13a2894796e45df60c92cf4c999b2974d400091 /src/models
parentFix lint errors (diff)
parentfix(App): Prevent app from redirecting when dropping link (diff)
downloadferdium-app-c55885e69e195e4413fda3bffffafeaee7c0c9d5.tar.gz
ferdium-app-c55885e69e195e4413fda3bffffafeaee7c0c9d5.tar.zst
ferdium-app-c55885e69e195e4413fda3bffffafeaee7c0c9d5.zip
Merge branch 'develop' into reload-crashed-service
Diffstat (limited to 'src/models')
-rw-r--r--src/models/Recipe.js19
-rw-r--r--src/models/Service.js7
2 files changed, 22 insertions, 4 deletions
diff --git a/src/models/Recipe.js b/src/models/Recipe.js
index 43a3450b1..9971df77c 100644
--- a/src/models/Recipe.js
+++ b/src/models/Recipe.js
@@ -1,7 +1,8 @@
1import emailParser from 'address-rfc2822';
2
1export default class Recipe { 3export default class Recipe {
2 id = ''; 4 id = '';
3 name = ''; 5 name = '';
4 author = '';
5 description = ''; 6 description = '';
6 version = '1.0'; 7 version = '1.0';
7 path = ''; 8 path = '';
@@ -25,12 +26,13 @@ export default class Recipe {
25 } 26 }
26 27
27 if (!data.id) { 28 if (!data.id) {
28 throw Error('Recipe requires Id'); 29 // Franz 4 recipes do not have an Id
30 throw Error(`Recipe '${data.name}' requires Id`);
29 } 31 }
30 32
31 this.id = data.id || this.id; 33 this.id = data.id || this.id;
32 this.name = data.name || this.name; 34 this.name = data.name || this.name;
33 this.author = data.author || this.author; 35 this.rawAuthor = data.author || this.author;
34 this.description = data.description || this.description; 36 this.description = data.description || this.description;
35 this.version = data.version || this.version; 37 this.version = data.version || this.version;
36 this.path = data.path; 38 this.path = data.path;
@@ -49,4 +51,15 @@ export default class Recipe {
49 51
50 this.message = data.config.message || this.message; 52 this.message = data.config.message || this.message;
51 } 53 }
54
55 get author() {
56 try {
57 const addresses = emailParser.parse(this.rawAuthor);
58 return addresses.map(a => ({ email: a.address, name: a.phrase }));
59 } catch (err) {
60 console.warn(`Not a valid author for ${this.name}`);
61 }
62
63 return [];
64 }
52} 65}
diff --git a/src/models/Service.js b/src/models/Service.js
index 89d6748b5..c7276821a 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -58,7 +58,12 @@ export default class Service {
58 58
59 @computed get url() { 59 @computed get url() {
60 if (this.recipe.hasCustomUrl && this.customUrl) { 60 if (this.recipe.hasCustomUrl && this.customUrl) {
61 let url = normalizeUrl(this.customUrl); 61 let url;
62 try {
63 url = normalizeUrl(this.customUrl);
64 } catch (err) {
65 console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`);
66 }
62 67
63 if (typeof this.recipe.buildUrl === 'function') { 68 if (typeof this.recipe.buildUrl === 'function') {
64 url = this.recipe.buildUrl(url); 69 url = this.recipe.buildUrl(url);