MCPcopy Index your code
hub / github.com/gitify-app/gitify / getGitHubAPIBaseUrl

Function getGitHubAPIBaseUrl

src/renderer/utils/api/utils.ts:8–27  ·  view source on GitHub ↗
(hostname: Hostname, type: APIClientType)

Source from the content-addressed store, hash-verified

6import { getPlatformFromHostname } from '../auth/platform';
7
8export function getGitHubAPIBaseUrl(hostname: Hostname, type: APIClientType) {
9 const platform = getPlatformFromHostname(hostname);
10 const url = new URL(Constants.GITHUB_API_BASE_URL);
11
12 switch (platform) {
13 case 'GitHub Enterprise Server':
14 url.hostname = hostname;
15 url.pathname = type === 'rest' ? '/api/v3/' : '/api/';
16 break;
17 case 'GitHub Enterprise Cloud with Data Residency':
18 url.hostname = `api.${hostname}`;
19 url.pathname = '/';
20 break;
21 default:
22 url.pathname = '/';
23 break;
24 }
25
26 return url;
27}
28
29export function getNumberFromUrl(url: string): number {
30 return Number.parseInt(url.split('/').pop()!, 10);

Callers 2

utils.test.tsFile · 0.90

Calls 1

getPlatformFromHostnameFunction · 0.90

Tested by

no test coverage detected