File tree Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import {
27
27
httpsCallable as _httpsCallable ,
28
28
httpsCallableFromURL as _httpsCallableFromURL
29
29
} from './service' ;
30
- import { getModularInstance } from '@firebase/util' ;
30
+ import { getModularInstance , getDefaultEmulatorHost } from '@firebase/util' ;
31
31
32
32
export * from './public-types' ;
33
33
@@ -51,12 +51,10 @@ export function getFunctions(
51
51
const functionsInstance = functionsProvider . getImmediate ( {
52
52
identifier : regionOrCustomDomain
53
53
} ) ;
54
- if ( app . name === '[DEFAULT]' || app . name . startsWith ( 'authenticated-context:' ) ) {
55
- const functionsEmulatorHost = ( globalThis as any ) . __FUNCTIONS_EMULATOR_HOST__ ;
56
- if ( functionsEmulatorHost ) {
57
- const [ host , port ] = functionsEmulatorHost . split ( ':' ) ;
58
- connectFunctionsEmulator ( functionsInstance , host , port ) ;
59
- }
54
+ const functionsEmulatorHost = getDefaultEmulatorHost ( 'functions' ) ;
55
+ if ( functionsEmulatorHost ) {
56
+ const [ host , port ] = functionsEmulatorHost . split ( ':' ) ;
57
+ connectFunctionsEmulator ( functionsInstance , host , parseInt ( port , 10 ) ) ;
60
58
}
61
59
return functionsInstance ;
62
60
}
Original file line number Diff line number Diff line change @@ -17,24 +17,14 @@ const getDefaultsFromGlobal = (): FirebaseDefaults|undefined => getGlobal().__FI
17
17
const getDefaultsFromEnvVariable = ( ) : FirebaseDefaults | undefined => {
18
18
if ( typeof process === 'undefined' ) return ;
19
19
const fromEnv = process . env . __FIREBASE_DEFAULTS__ ;
20
- try {
21
- return fromEnv && JSON . parse ( fromEnv ) ;
22
- } catch ( e ) {
23
- console . error ( e ) ;
24
- }
20
+ return fromEnv && JSON . parse ( fromEnv ) ;
25
21
} ;
26
22
27
23
const getDefaultsFromCookie = ( ) : FirebaseDefaults | undefined => {
28
24
if ( typeof document === 'undefined' ) return ;
29
25
const match = document . cookie . match ( / _ _ F I R E B A S E _ D E F A U L T S _ _ = ( [ ^ ; ] + ) / ) ;
30
- if ( ! match ) return ;
31
- const decoded = base64Decode ( match [ 1 ] ) ;
32
- if ( ! decoded ) return ;
33
- try {
34
- return JSON . parse ( decoded ) ;
35
- } catch ( e ) {
36
- console . error ( e ) ;
37
- }
26
+ const decoded = match && base64Decode ( match [ 1 ] ) ;
27
+ return decoded && JSON . parse ( decoded ) ;
38
28
} ;
39
29
40
30
const getDefaults = ( ) => getDefaultsFromGlobal ( ) ||
You can’t perform that action at this time.
0 commit comments