aboutsummaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-03 23:22:38 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-11-03 23:22:38 +0100
commita54c87be1ce629cf13a5bfb9c2ba26958e0e4e74 (patch)
treeda5535da9fd3af1dee6ad706bead7b8e4263468b /src/models
parentReset linux shortcuts to Ctrl (diff)
downloadferdium-app-a54c87be1ce629cf13a5bfb9c2ba26958e0e4e74.tar.gz
ferdium-app-a54c87be1ce629cf13a5bfb9c2ba26958e0e4e74.tar.zst
ferdium-app-a54c87be1ce629cf13a5bfb9c2ba26958e0e4e74.zip
Parse recipe author string
Diffstat (limited to 'src/models')
-rw-r--r--src/models/Recipe.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/models/Recipe.js b/src/models/Recipe.js
index 43a3450b1..4b613a40c 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 = '';
@@ -30,7 +31,7 @@ export default class Recipe {
30 31
31 this.id = data.id || this.id; 32 this.id = data.id || this.id;
32 this.name = data.name || this.name; 33 this.name = data.name || this.name;
33 this.author = data.author || this.author; 34 this.rawAuthor = data.author || this.author;
34 this.description = data.description || this.description; 35 this.description = data.description || this.description;
35 this.version = data.version || this.version; 36 this.version = data.version || this.version;
36 this.path = data.path; 37 this.path = data.path;
@@ -49,4 +50,15 @@ export default class Recipe {
49 50
50 this.message = data.config.message || this.message; 51 this.message = data.config.message || this.message;
51 } 52 }
53
54 get author() {
55 try {
56 const addresses = emailParser.parse(this.rawAuthor);
57 return addresses.map(a => ({ email: a.address, name: a.phrase }));
58 } catch (err) {
59 console.warn(`Not a valid author for ${this.name}`);
60 }
61
62 return [];
63 }
52} 64}