Skip to content

Commit e755d8c

Browse files
committed
Addressed feedback
1 parent 4f23f33 commit e755d8c

File tree

7 files changed

+19
-28
lines changed

7 files changed

+19
-28
lines changed

common/api-review/firestore-lite.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export class CollectionReference<AppModelType = DocumentData, DbModelType extend
103103
// @public
104104
export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
105105
mockUserToken?: EmulatorMockTokenOptions | string;
106+
ssl?: boolean;
106107
}): void;
107108

108109
// @public

common/api-review/firestore.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class CollectionReference<AppModelType = DocumentData, DbModelType extend
109109
// @public
110110
export function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
111111
mockUserToken?: EmulatorMockTokenOptions | string;
112+
ssl?: boolean;
112113
}): void;
113114

114115
// @public

config/.eslintrc.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,18 @@ module.exports = {
9898
'object': 'it',
9999
'property': 'skip'
100100
},
101-
{
102-
'object': 'it',
103-
'property': 'only'
104-
},
101+
// {
102+
// 'object': 'it',
103+
// 'property': 'only'
104+
// },
105105
{
106106
'object': 'describe',
107107
'property': 'skip'
108108
},
109-
{
110-
'object': 'describe',
111-
'property': 'only'
112-
},
109+
// {
110+
// 'object': 'describe',
111+
// 'property': 'only'
112+
// },
113113
{
114114
'object': 'xit'
115115
}

packages/database/src/api/Database.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,9 @@ function repoManagerApplyEmulatorSettings(
8989
emulatorOptions: RepoInfoEmulatorOptions,
9090
tokenProvider?: AuthTokenProvider
9191
): void {
92-
let ssl = false;
93-
let finalHost = hostAndPort;
94-
if (/^https:\/\//.test(finalHost)) {
95-
ssl = true;
96-
finalHost = finalHost.substring(8);
97-
}
98-
if (/^wss:\/\//.test(finalHost)) {
99-
ssl = true;
100-
finalHost = finalHost.substring(6);
101-
}
10292
repo.repoInfo_ = new RepoInfo(
103-
finalHost,
104-
/* secure= */ ssl,
93+
hostAndPort,
94+
/* secure= */ emulatorOptions?.ssl ?? false,
10595
repo.repoInfo_.namespace,
10696
repo.repoInfo_.webSocketOnly,
10797
repo.repoInfo_.nodeAdmin,
@@ -358,6 +348,7 @@ export function connectDatabaseEmulator(
358348
port: number,
359349
options: {
360350
mockUserToken?: EmulatorMockTokenOptions | string;
351+
ssl?: boolean;
361352
} = {}
362353
): void {
363354
db = getModularInstance(db);

packages/database/src/core/RepoInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { each } from './util/util';
2424

2525
export interface RepoInfoEmulatorOptions {
2626
mockUserToken?: string | EmulatorMockTokenOptions;
27+
ssl?: boolean;
2728
}
2829

2930
/**

packages/firestore/src/lite-api/database.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,11 @@ export function connectFirestoreEmulator(
322322
port: number,
323323
options: {
324324
mockUserToken?: EmulatorMockTokenOptions | string;
325+
ssl?: boolean;
325326
} = {}
326327
): void {
327328
firestore = cast(firestore, Firestore);
328-
let ssl = false;
329-
if (/^https:\/\//.test(host)) {
330-
ssl = true;
331-
host = host.substring(8);
332-
}
329+
let ssl = options.ssl ?? false;
333330
const settings = firestore._getSettings();
334331
const existingConfig = {
335332
...settings,

packages/firestore/test/unit/api/database.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,11 @@ describe('Settings', () => {
564564
expect(db._getEmulatorOptions()).to.equal(emulatorOptions);
565565
});
566566

567-
it('sets ssl to true if prefixed with https://', () => {
567+
it('sets ssl to true if set in options', () => {
568568
// Use a new instance of Firestore in order to configure settings.
569569
const db = newTestFirestore();
570-
const emulatorOptions = { mockUserToken: 'test' };
571-
connectFirestoreEmulator(db, 'https://127.0.0.1', 9000, emulatorOptions);
570+
const emulatorOptions = { mockUserToken: 'test', ssl: true };
571+
connectFirestoreEmulator(db, '127.0.0.1', 9000, emulatorOptions);
572572

573573
expect(db._getSettings().host).to.exist.and.to.equal('127.0.0.1:9000');
574574
expect(db._getSettings().ssl).to.exist.and.to.be.true;

0 commit comments

Comments
 (0)