File tree 3 files changed +8
-7
lines changed
3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { setAutoLaunch } from '../utils/comms';
22
22
import { useInterval } from '../hooks/useInterval' ;
23
23
import { useNotifications } from '../hooks/useNotifications' ;
24
24
import Constants from '../utils/constants' ;
25
+ import { generateGitHubAPIUrl } from '../utils/helpers' ;
25
26
26
27
const defaultAccounts : AuthState = {
27
28
token : null ,
@@ -134,7 +135,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
134
135
const validateToken = useCallback (
135
136
async ( { token, hostname } : AuthTokenOptions ) => {
136
137
await apiRequestAuth (
137
- `https://api. ${ hostname } / notifications` ,
138
+ `${ generateGitHubAPIUrl ( hostname ) } notifications` ,
138
139
'HEAD' ,
139
140
token
140
141
) ;
Original file line number Diff line number Diff line change @@ -57,16 +57,14 @@ export const useNotifications = (): NotificationsState => {
57
57
if ( ! isGitHubLoggedIn ) {
58
58
return ;
59
59
}
60
- const url = `https://api. ${ Constants . DEFAULT_AUTH_OPTIONS . hostname } / ${ endpointSuffix } ` ;
60
+ const url = `${ generateGitHubAPIUrl ( Constants . DEFAULT_AUTH_OPTIONS . hostname ) } ${ endpointSuffix } ` ;
61
61
return apiRequestAuth ( url , 'GET' , accounts . token ) ;
62
62
}
63
63
64
64
function getEnterpriseNotifications ( ) {
65
65
return accounts . enterpriseAccounts . map ( ( account ) => {
66
- const hostname = account . hostname ;
67
- const token = account . token ;
68
- const url = `https://${ hostname } /api/v3/${ endpointSuffix } ` ;
69
- return apiRequestAuth ( url , 'GET' , token ) ;
66
+ const url = `${ generateGitHubAPIUrl ( account . hostname ) } ${ endpointSuffix } ` ;
67
+ return apiRequestAuth ( url , 'GET' , account . token ) ;
70
68
} ) ;
71
69
}
72
70
Original file line number Diff line number Diff line change
1
+ import { generateGitHubAPIUrl } from "./helpers" ;
2
+
1
3
const { remote } = require ( 'electron' ) ;
2
4
const BrowserWindow = remote . BrowserWindow ;
3
5
@@ -78,7 +80,7 @@ export const getUserData = async (
78
80
hostname : string
79
81
) : Promise < User > => {
80
82
const response = await apiRequestAuth (
81
- `https://api. ${ hostname } / user` ,
83
+ `${ generateGitHubAPIUrl ( hostname ) } user` ,
82
84
'GET' ,
83
85
token
84
86
) ;
You can’t perform that action at this time.
0 commit comments