Skip to content

Commit 6d63073

Browse files
committed
Make param required
1 parent 862fb91 commit 6d63073

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

packages/storage/src/implementation/connection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export interface Connection<T extends ConnectionType> {
4242
send(
4343
url: string,
4444
method: string,
45+
isUsingEmulator: boolean,
4546
body?: ArrayBufferView | Blob | string | null,
46-
headers?: Headers,
47-
isUsingEmulator?: boolean
47+
headers?: Headers
4848
): Promise<void>;
4949

5050
getErrorCode(): ErrorCode;

packages/storage/src/platform/node/connection.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ abstract class FetchConnection<T extends ConnectionType>
4949
async send(
5050
url: string,
5151
method: string,
52+
isUsingEmulator: boolean,
5253
body?: NodeJS.ArrayBufferView | Blob | string,
53-
headers?: Record<string, string>,
54-
isUsingEmulator?: boolean
54+
headers?: Record<string, string>
5555
): Promise<void> {
5656
if (this.sent_) {
5757
throw internalError('cannot .send() more than once');
@@ -62,9 +62,9 @@ abstract class FetchConnection<T extends ConnectionType>
6262
const response = await newFetch(
6363
url,
6464
method,
65+
isUsingEmulator,
6566
headers,
66-
body,
67-
isUsingEmulator
67+
body
6868
);
6969
this.headers_ = response.headers;
7070
this.statusCode_ = response.status;
@@ -156,9 +156,9 @@ export class FetchStreamConnection extends FetchConnection<
156156
async send(
157157
url: string,
158158
method: string,
159+
isUsingEmulator: boolean,
159160
body?: NodeJS.ArrayBufferView | Blob | string,
160-
headers?: Record<string, string>,
161-
isUsingEmulator?: boolean
161+
headers?: Record<string, string>
162162
): Promise<void> {
163163
if (this.sent_) {
164164
throw internalError('cannot .send() more than once');
@@ -169,9 +169,9 @@ export class FetchStreamConnection extends FetchConnection<
169169
const response = await newFetch(
170170
url,
171171
method,
172+
isUsingEmulator,
172173
headers,
173-
body,
174-
isUsingEmulator
174+
body
175175
);
176176
this.headers_ = response.headers;
177177
this.statusCode_ = response.status;
@@ -196,9 +196,9 @@ export class FetchStreamConnection extends FetchConnection<
196196
function newFetch(
197197
url: string,
198198
method: string,
199+
isUsingEmulator: boolean,
199200
headers?: Record<string, string>,
200-
body?: NodeJS.ArrayBufferView | Blob | string,
201-
isUsingEmulator?: boolean
201+
body?: NodeJS.ArrayBufferView | Blob | string
202202
): Promise<Response> {
203203
const fetchArgs: RequestInit = {
204204
method,

packages/storage/src/service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export function connectStorageEmulator(
146146
): void {
147147
storage.host = `${host}:${port}`;
148148
const useSsl = isCloudWorkstation(host);
149+
storage._isUsingEmulator = true;
149150
storage._protocol = useSsl ? 'https' : 'http';
150151
const { mockUserToken } = options;
151152
if (mockUserToken) {
@@ -193,7 +194,7 @@ export class FirebaseStorageImpl implements FirebaseStorage {
193194
*/
194195
readonly _url?: string,
195196
readonly _firebaseVersion?: string,
196-
readonly _isUsingEmulator = false
197+
public _isUsingEmulator = false
197198
) {
198199
this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;
199200
this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;

packages/storage/test/node/connection.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Connections', () => {
2525
const connection = new FetchBytesConnection();
2626

2727
const fetchStub = stub(globalThis, 'fetch').rejects();
28-
await connection.send('testurl', 'GET');
28+
await connection.send('testurl', 'GET', false);
2929
expect(connection.getErrorCode()).to.equal(ErrorCode.NETWORK_ERROR);
3030
fetchStub.restore();
3131
});

packages/storage/test/unit/connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class TestingConnection implements Connection<string> {
6060
send(
6161
url: string,
6262
method: string,
63+
_isUsingEmulator: boolean,
6364
body?: ArrayBufferView | Blob | string | null,
6465
headers?: Headers
6566
): Promise<void> {

packages/storage/test/unit/service.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ GOOG4-RSA-SHA256`
287287
textConnection.send(
288288
'http://something.cloudworkstations.dev',
289289
'POST',
290+
true,
290291
undefined,
291-
undefined,
292-
true
292+
undefined
293293
);
294294
expect(stub).to.have.been.called;
295295
expect(stub).to.have.been.calledWithMatch(

0 commit comments

Comments
 (0)