-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
76 lines (72 loc) · 1.88 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* @typedef {Object} Provider
* @property {string} id
* @property {string} url — url of web interface
* @property {string} label — label that can be outputed into UI
* @property {string[]} keywords — keyword that can be used to determine that email belongs to the provider
*/
/** @constant
* @type {Provider[]}
*/
export const PROVIDERS = [
{
id: 'GMAIL',
url: 'https://mail.google.com/',
label: 'GMail',
keywords: ['@gmail'],
},
{
id: 'MAILRU',
url: 'https://e.mail.ru/inbox/',
label: 'Mail.ru',
keywords: ['@mail.ru'],
},
{
id: 'FASTMAIL',
url: 'https://app.fastmail.com/mail/Inbox/?u=95c940d4',
label: 'Fastmail',
keywords: ['@fastmail'],
},
{
id: 'OUTLOOK',
url: 'https://outlook.live.com/',
label: 'Outlook',
keywords: ['@outlook'],
},
{
id: 'YAHOO',
url: 'https://mail.yahoo.com',
label: 'Yahoo',
keywords: ['@yahoo', '@myyahoo'],
},
{
id: 'ZOHO',
url: 'https://mail.zoho.com',
label: 'Zoho',
keywords: ['@zohomail'],
},
{
id: 'APPLE',
url: 'https://www.icloud.com/mail/',
label: 'iCloud Mail',
keywords: ['@icloud'],
},
];
/**
* Gets provider by id
* @param {string} id - id of provider
* @returns {(Provider | undefined)} — returns provider object if found, and undefined if not found
*/
export const getProvider = (id) =>
PROVIDERS.find((provider) => provider.id === id); //#FIXME Completely rename to getProviderById in next version
export const getProviderById = getProvider;
/**
* Gets provider from email
* @param {string} email - email to search
* @returns {(Provider | undefined)} — returns provider object if found, and undefined if not found
*/
export const getProviderByEmail = (email) =>
PROVIDERS.find((provider) => {
return provider.keywords.find((keyword) => email.includes(keyword));
});
export default PROVIDERS;