@@ -58,7 +58,6 @@ export interface ConnectorConfig {
5858export interface TransportOptions {
5959 host : string ;
6060 sslEnabled ?: boolean ;
61- port ?: number ;
6261}
6362
6463const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR =
@@ -71,11 +70,15 @@ const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR =
7170 * @internal
7271 */
7372export function parseOptions ( fullHost : string ) : TransportOptions {
74- const [ protocol , hostName ] = fullHost . split ( '://' ) ;
75- const isSecure = protocol === 'https' ;
76- const [ host , portAsString ] = hostName . split ( ':' ) ;
77- const port = Number ( portAsString ) ;
78- return { host, port, sslEnabled : isSecure } ;
73+ if ( fullHost . startsWith ( 'http://' ) || fullHost . startsWith ( 'https://' ) ) {
74+ const [ protocol , host ] = fullHost . split ( '://' ) ;
75+ const isSecure = protocol === 'https' ;
76+ return { host, sslEnabled : isSecure } ;
77+ }
78+ return {
79+ host : fullHost ,
80+ sslEnabled : false
81+ } ;
7982}
8083/**
8184 * DataConnectOptions including project id
@@ -182,7 +185,6 @@ export class DataConnect {
182185 if ( this . _transportOptions ) {
183186 this . _transport . useEmulator (
184187 this . _transportOptions . host ,
185- this . _transportOptions . port ,
186188 this . _transportOptions . sslEnabled
187189 ) ;
188190 }
@@ -219,7 +221,6 @@ export function areTransportOptionsEqual(
219221) : boolean {
220222 return (
221223 transportOptions1 . host === transportOptions2 . host &&
222- transportOptions1 . port === transportOptions2 . port &&
223224 transportOptions1 . sslEnabled === transportOptions2 . sslEnabled
224225 ) ;
225226}
@@ -237,7 +238,8 @@ export function connectDataConnectEmulator(
237238 port ?: number ,
238239 sslEnabled = false
239240) : void {
240- dc . enableEmulator ( { host, port, sslEnabled } ) ;
241+ const hostWithPort = port ? `${ host } :${ port } ` : host ;
242+ dc . enableEmulator ( { host : hostWithPort , sslEnabled } ) ;
241243}
242244
243245/**
0 commit comments