aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/github_entreprise/index.js
blob: f15e5cb8798e79ade4603822dc565b8a2053ea92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"use strict";

module.exports = Franz => class GitHubEnterprise extends Franz {
  async validateUrl(url) {
    try {
      const resp = await window.fetch(`${url}/api/v3`, {
        method: 'GET',
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/vnd.github.v3+json'
        },
      });
      //doc: https://developer.github.com/enterprise/2.17/v3/#current-version
      return resp.status.toString().startsWith('2');
    } catch (err) {
      console.error(err);
    }

    return false;
  }
};