Skip to content

Commit e61abc0

Browse files
authored
refactor: rename isEnterpriseHost helper (#1413)
1 parent 5ee1586 commit e61abc0

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/utils/api/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { Hostname } from '../../types';
22
import Constants from '../constants';
3-
import { isEnterpriseHost } from '../helpers';
3+
import { isEnterpriseServerHost } from '../helpers';
44

55
export function getGitHubAPIBaseUrl(hostname: Hostname): URL {
66
const url = new URL(Constants.GITHUB_API_BASE_URL);
77

8-
if (isEnterpriseHost(hostname)) {
8+
if (isEnterpriseServerHost(hostname)) {
99
url.hostname = hostname;
1010
url.pathname = '/api/v3/';
1111
}
@@ -15,7 +15,7 @@ export function getGitHubAPIBaseUrl(hostname: Hostname): URL {
1515
export function getGitHubGraphQLUrl(hostname: Hostname): URL {
1616
const url = new URL(Constants.GITHUB_API_GRAPHQL_URL);
1717

18-
if (isEnterpriseHost(hostname)) {
18+
if (isEnterpriseServerHost(hostname)) {
1919
url.hostname = hostname;
2020
url.pathname = '/api/graphql';
2121
}

src/utils/helpers.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
generateNotificationReferrerId,
1717
getFilterCount,
1818
getPlatformFromHostname,
19-
isEnterpriseHost,
19+
isEnterpriseServerHost,
2020
} from './helpers';
2121

2222
describe('utils/helpers.ts', () => {
@@ -40,15 +40,19 @@ describe('utils/helpers.ts', () => {
4040
});
4141
});
4242

43-
describe('isEnterpriseHost', () => {
43+
describe('isEnterpriseServerHost', () => {
4444
it('should return true for enterprise host', () => {
45-
expect(isEnterpriseHost('github.gitify.app' as Hostname)).toBe(true);
46-
expect(isEnterpriseHost('api.github.gitify.app' as Hostname)).toBe(true);
45+
expect(isEnterpriseServerHost('github.gitify.app' as Hostname)).toBe(
46+
true,
47+
);
48+
expect(isEnterpriseServerHost('api.github.gitify.app' as Hostname)).toBe(
49+
true,
50+
);
4751
});
4852

4953
it('should return false for non-enterprise host', () => {
50-
expect(isEnterpriseHost('github.com' as Hostname)).toBe(false);
51-
expect(isEnterpriseHost('api.github.com' as Hostname)).toBe(false);
54+
expect(isEnterpriseServerHost('github.com' as Hostname)).toBe(false);
55+
expect(isEnterpriseServerHost('api.github.com' as Hostname)).toBe(false);
5256
});
5357
});
5458

src/utils/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function getPlatformFromHostname(hostname: string): PlatformType {
1717
: 'GitHub Enterprise Server';
1818
}
1919

20-
export function isEnterpriseHost(hostname: Hostname): boolean {
20+
export function isEnterpriseServerHost(hostname: Hostname): boolean {
2121
return !hostname.endsWith(Constants.DEFAULT_AUTH_OPTIONS.hostname);
2222
}
2323

0 commit comments

Comments
 (0)