diff options
Diffstat (limited to 'recipes/zulip/index.js')
-rw-r--r-- | recipes/zulip/index.js | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/recipes/zulip/index.js b/recipes/zulip/index.js index 13c94b7..ea3944f 100644 --- a/recipes/zulip/index.js +++ b/recipes/zulip/index.js | |||
@@ -1,21 +1,25 @@ | |||
1 | module.exports = Ferdium => class Zulip extends Ferdium { | 1 | module.exports = Ferdium => |
2 | async validateUrl(url) { | 2 | class Zulip extends Ferdium { |
3 | const baseUrl = new window.URL(url); | 3 | async validateUrl(url) { |
4 | const apiVersion = 'api/v1'; | 4 | const baseUrl = new window.URL(url); |
5 | try { | 5 | const apiVersion = 'api/v1'; |
6 | const resp = await window.fetch(`${baseUrl.origin}/${apiVersion}/server_settings`, { | 6 | try { |
7 | method: 'GET', | 7 | const resp = await window.fetch( |
8 | headers: { | 8 | `${baseUrl.origin}/${apiVersion}/server_settings`, |
9 | 'Content-Type': 'application/json', | 9 | { |
10 | }, | 10 | method: 'GET', |
11 | }); | 11 | headers: { |
12 | const data = await resp.json(); | 12 | 'Content-Type': 'application/json', |
13 | }, | ||
14 | }, | ||
15 | ); | ||
16 | const data = await resp.json(); | ||
13 | 17 | ||
14 | return Object.hasOwnProperty.call(data, 'realm_uri'); | 18 | return Object.hasOwnProperty.call(data, 'realm_uri'); |
15 | } catch (error) { | 19 | } catch (error) { |
16 | console.error(error); | 20 | console.error(error); |
17 | } | 21 | } |
18 | 22 | ||
19 | return false; | 23 | return false; |
20 | } | 24 | } |
21 | }; | 25 | }; |