@@ -315,6 +315,8 @@ export class Firestore {
315
315
* support {@link https://cloud.google.com/docs/authentication Application
316
316
* Default Credentials}. If your credentials are stored in a JSON file, you
317
317
* can specify a `keyFilename` instead.
318
+ * @param {string= } settings.host The host to connect to.
319
+ * @param {boolean= } settings.ssl Whether to use SSL when connecting.
318
320
* @param {boolean= } settings.timestampsInSnapshots Specifies whether to use
319
321
* `Timestamp` objects for timestamp fields in `DocumentSnapshot`s. This is
320
322
* enabled by default and should not be disabled.
@@ -346,13 +348,8 @@ export class Firestore {
346
348
process . env . FIRESTORE_EMULATOR_HOST
347
349
) ;
348
350
349
- const url = new URL ( 'http://' + process . env . FIRESTORE_EMULATOR_HOST ) ;
350
- const host = url . hostname ;
351
- const port = url . port !== '' ? Number ( url . port ) : undefined ;
352
-
353
351
this . validateAndApplySettings ( {
354
- host,
355
- port,
352
+ host : process . env . FIRESTORE_EMULATOR_HOST ,
356
353
ssl : false ,
357
354
customHeaders : {
358
355
Authorization : 'Bearer owner' ,
@@ -457,7 +454,12 @@ export class Firestore {
457
454
'Cannot set both "settings.host" and "settings.apiEndpoint".'
458
455
) ;
459
456
}
460
- settings . servicePath = settings . host ;
457
+
458
+ const url = new URL ( `http://${ settings . host } ` ) ;
459
+ settings . servicePath = url . hostname ;
460
+ if ( url . port !== '' && settings . port === undefined ) {
461
+ settings . port = Number ( url . port ) ;
462
+ }
461
463
}
462
464
463
465
if ( settings . ssl !== undefined ) {
0 commit comments