Skip to content

Commit 03cc08e

Browse files
committed
PR feedback
1 parent 1b9cfaa commit 03cc08e

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages-exp/auth-exp/src/api/authentication/token.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919

2020
import { querystring } from '@firebase/util';
2121

22-
import {
23-
_getFinalTarget,
24-
_performFetchWithErrorHandling,
25-
HttpMethod
26-
} from '../';
22+
import { _getFinalTarget, _performFetchWithErrorHandling, HttpMethod } from '../';
2723
import { FetchProvider } from '../../core/util/fetch_provider';
2824
import { AuthCore } from '../../model/auth';
2925

@@ -54,10 +50,12 @@ export async function requestStsToken(
5450
'grant_type': GRANT_TYPE,
5551
'refresh_token': refreshToken
5652
}).slice(1);
57-
const { apiScheme, tokenApiHost, apiKey, sdkClientVersion } = auth.config;
53+
const { tokenApiHost, apiKey, sdkClientVersion } = auth.config;
5854
const url = _getFinalTarget(
5955
auth,
60-
`${apiScheme}://${tokenApiHost}/${_ENDPOINT}`
56+
tokenApiHost,
57+
_ENDPOINT,
58+
`key=${apiKey}`,
6159
);
6260

6361
return FetchProvider.fetch()(`${url}?key=${apiKey}`, {

packages-exp/auth-exp/src/api/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ export async function _performApiRequest<T, V>(
9797
return FetchProvider.fetch()(
9898
_getFinalTarget(
9999
auth,
100-
`${auth.config.apiScheme}://${auth.config.apiHost}${path}?${query}`
101-
),
100+
auth.config.apiHost,
101+
path,
102+
query),
102103
{
103104
method,
104105
headers,
@@ -183,14 +184,15 @@ export async function _performSignInRequest<T, V extends IdTokenResponse>(
183184
return serverResponse;
184185
}
185186

186-
export function _getFinalTarget(auth: AuthCore, url: string): string {
187+
export function _getFinalTarget(auth: AuthCore, host: string, path: string, query: string): string {
187188
const { emulator } = auth.config;
189+
const base = `${host}${path}?${query}`;
190+
188191
if (!emulator) {
189-
return url;
192+
return `${auth.config.apiScheme}://${base}`;
190193
}
191194

192-
const urlWithoutScheme = url.replace(/^.*:\/\//, '');
193-
return `http://${emulator.hostname}:${emulator.port}/${urlWithoutScheme}`;
195+
return `http://${emulator.hostname}:${emulator.port}/${base}`;
194196
}
195197

196198
function makeNetworkTimeout<T>(appName: string): Promise<T> {

0 commit comments

Comments
 (0)