aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/rocketchat/index.js
blob: 97de4fee622c7ae9c3cf2472ef43d8965e9ea233 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = Ferdi => class RocketChat extends Ferdi {
  async validateUrl(url) {
    try {
      const resp = await window.fetch(url, {
        method: 'GET',
        headers: {
          'Content-Type': 'application/json',
        },
      });
      const status = resp.status.toString();
      return status.startsWith('2') || status.startsWith('3');
    } catch (error) {
      console.error(error);
    }

    return false;
  }
};