@@ -315,6 +315,8 @@ export class Firestore {
315315 * support {@link https://cloud.google.com/docs/authentication Application
316316 * Default Credentials}. If your credentials are stored in a JSON file, you
317317 * 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.
318320 * @param {boolean= } settings.timestampsInSnapshots Specifies whether to use
319321 * `Timestamp` objects for timestamp fields in `DocumentSnapshot`s. This is
320322 * enabled by default and should not be disabled.
@@ -346,13 +348,8 @@ export class Firestore {
346348 process . env . FIRESTORE_EMULATOR_HOST
347349 ) ;
348350
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-
353351 this . validateAndApplySettings ( {
354- host,
355- port,
352+ host : process . env . FIRESTORE_EMULATOR_HOST ,
356353 ssl : false ,
357354 customHeaders : {
358355 Authorization : 'Bearer owner' ,
@@ -457,7 +454,12 @@ export class Firestore {
457454 'Cannot set both "settings.host" and "settings.apiEndpoint".'
458455 ) ;
459456 }
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+ }
461463 }
462464
463465 if ( settings . ssl !== undefined ) {
0 commit comments