Skip to content

Commit d625eb5

Browse files
committed
Complete solution
1 parent 0034772 commit d625eb5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

packages/firestore/src/remote/rest_connection.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
import { SDK_VERSION } from '../../src/core/version';
1919
import { Token } from '../api/credentials';
20-
import { DatabaseId, DatabaseInfo } from '../core/database_info';
20+
import {
21+
DatabaseId,
22+
DatabaseInfo,
23+
DEFAULT_DATABASE_NAME
24+
} from '../core/database_info';
2125
import { debugAssert } from '../util/assert';
2226
import { generateUniqueDebugId } from '../util/debug_uid';
2327
import { FirestoreError } from '../util/error';
@@ -86,7 +90,10 @@ export abstract class RestConnection implements Connection {
8690
logDebug(LOG_TAG, `Sending RPC '${rpcName}' ${streamId}:`, url, req);
8791

8892
const headers: StringMap = {
89-
'x-goog-request-params': `project_id=${this.databaseId.projectId}&database_id=${this.databaseId.database}`
93+
'x-goog-request-params':
94+
this.databaseId.database === DEFAULT_DATABASE_NAME
95+
? `project_id=${this.databaseId.projectId}`
96+
: `project_id=${this.databaseId.projectId}&database_id=${this.databaseId.database}`
9097
};
9198
this.modifyHeadersForRequest(headers, authToken, appCheckToken);
9299

packages/firestore/test/unit/remote/rest_connection.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class TestRestConnection extends RestConnection {
5656
}
5757
}
5858

59-
describe('RestConnection', () => {
59+
describe.only('RestConnection', () => {
6060
const testDatabaseInfo = new DatabaseInfo(
6161
new DatabaseId('testproject'),
6262
'test-app-id',
@@ -97,7 +97,7 @@ describe('RestConnection', () => {
9797
'X-Firebase-GMPID': 'test-app-id',
9898
'X-Goog-Api-Client': `gl-js/ fire/${SDK_VERSION}`,
9999
'x-firebase-appcheck': 'some-app-check-token',
100-
'x-goog-request-params': 'project_id=testproject&database_id=(default)'
100+
'x-goog-request-params': 'project_id=testproject'
101101
});
102102
});
103103

@@ -113,7 +113,7 @@ describe('RestConnection', () => {
113113
'Content-Type': 'text/plain',
114114
'X-Firebase-GMPID': 'test-app-id',
115115
'X-Goog-Api-Client': `gl-js/ fire/${SDK_VERSION}`,
116-
'x-goog-request-params': 'project_id=testproject&database_id=(default)'
116+
'x-goog-request-params': 'project_id=testproject'
117117
// Note: AppCheck token should not exist here.
118118
});
119119
});

0 commit comments

Comments
 (0)