File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
Expand file tree Collapse file tree 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';
2222import { useInterval } from '../hooks/useInterval' ;
2323import { useNotifications } from '../hooks/useNotifications' ;
2424import Constants from '../utils/constants' ;
25+ import { generateGitHubAPIUrl } from '../utils/helpers' ;
2526
2627const defaultAccounts : AuthState = {
2728 token : null ,
@@ -134,7 +135,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
134135 const validateToken = useCallback (
135136 async ( { token, hostname } : AuthTokenOptions ) => {
136137 await apiRequestAuth (
137- `https://api. ${ hostname } / notifications` ,
138+ `${ generateGitHubAPIUrl ( hostname ) } notifications` ,
138139 'HEAD' ,
139140 token
140141 ) ;
Original file line number Diff line number Diff line change @@ -57,16 +57,14 @@ export const useNotifications = (): NotificationsState => {
5757 if ( ! isGitHubLoggedIn ) {
5858 return ;
5959 }
60- const url = `https://api. ${ Constants . DEFAULT_AUTH_OPTIONS . hostname } / ${ endpointSuffix } ` ;
60+ const url = `${ generateGitHubAPIUrl ( Constants . DEFAULT_AUTH_OPTIONS . hostname ) } ${ endpointSuffix } ` ;
6161 return apiRequestAuth ( url , 'GET' , accounts . token ) ;
6262 }
6363
6464 function getEnterpriseNotifications ( ) {
6565 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 ) ;
7068 } ) ;
7169 }
7270
Original file line number Diff line number Diff line change 1+ import { generateGitHubAPIUrl } from "./helpers" ;
2+
13const { remote } = require ( 'electron' ) ;
24const BrowserWindow = remote . BrowserWindow ;
35
@@ -78,7 +80,7 @@ export const getUserData = async (
7880 hostname : string
7981) : Promise < User > => {
8082 const response = await apiRequestAuth (
81- `https://api. ${ hostname } / user` ,
83+ `${ generateGitHubAPIUrl ( hostname ) } user` ,
8284 'GET' ,
8385 token
8486 ) ;
You can’t perform that action at this time.
0 commit comments