File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
packages-exp/auth-exp/src/api Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 19
19
20
20
import { querystring } from '@firebase/util' ;
21
21
22
- import {
23
- _getFinalTarget ,
24
- _performFetchWithErrorHandling ,
25
- HttpMethod
26
- } from '../' ;
22
+ import { _getFinalTarget , _performFetchWithErrorHandling , HttpMethod } from '../' ;
27
23
import { FetchProvider } from '../../core/util/fetch_provider' ;
28
24
import { AuthCore } from '../../model/auth' ;
29
25
@@ -54,10 +50,12 @@ export async function requestStsToken(
54
50
'grant_type' : GRANT_TYPE ,
55
51
'refresh_token' : refreshToken
56
52
} ) . slice ( 1 ) ;
57
- const { apiScheme , tokenApiHost, apiKey, sdkClientVersion } = auth . config ;
53
+ const { tokenApiHost, apiKey, sdkClientVersion } = auth . config ;
58
54
const url = _getFinalTarget (
59
55
auth ,
60
- `${ apiScheme } ://${ tokenApiHost } /${ _ENDPOINT } `
56
+ tokenApiHost ,
57
+ _ENDPOINT ,
58
+ `key=${ apiKey } ` ,
61
59
) ;
62
60
63
61
return FetchProvider . fetch ( ) ( `${ url } ?key=${ apiKey } ` , {
Original file line number Diff line number Diff line change @@ -97,8 +97,9 @@ export async function _performApiRequest<T, V>(
97
97
return FetchProvider . fetch ( ) (
98
98
_getFinalTarget (
99
99
auth ,
100
- `${ auth . config . apiScheme } ://${ auth . config . apiHost } ${ path } ?${ query } `
101
- ) ,
100
+ auth . config . apiHost ,
101
+ path ,
102
+ query ) ,
102
103
{
103
104
method,
104
105
headers,
@@ -183,14 +184,15 @@ export async function _performSignInRequest<T, V extends IdTokenResponse>(
183
184
return serverResponse ;
184
185
}
185
186
186
- export function _getFinalTarget ( auth : AuthCore , url : string ) : string {
187
+ export function _getFinalTarget ( auth : AuthCore , host : string , path : string , query : string ) : string {
187
188
const { emulator } = auth . config ;
189
+ const base = `${ host } ${ path } ?${ query } ` ;
190
+
188
191
if ( ! emulator ) {
189
- return url ;
192
+ return ` ${ auth . config . apiScheme } :// ${ base } ` ;
190
193
}
191
194
192
- const urlWithoutScheme = url . replace ( / ^ .* : \/ \/ / , '' ) ;
193
- return `http://${ emulator . hostname } :${ emulator . port } /${ urlWithoutScheme } ` ;
195
+ return `http://${ emulator . hostname } :${ emulator . port } /${ base } ` ;
194
196
}
195
197
196
198
function makeNetworkTimeout < T > ( appName : string ) : Promise < T > {
You can’t perform that action at this time.
0 commit comments