Skip to content

Commit 8518b6b

Browse files
Update Console domains for RTDB SDK (#4154)
1 parent 3754371 commit 8518b6b

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

packages/database/src/realtime/BrowserPollConnection.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { StatsManager } from '../core/stats/StatsManager';
2828
import { PacketReceiver } from './polling/PacketReceiver';
2929
import {
3030
APPLICATION_ID_PARAM,
31-
FORGE_DOMAIN,
31+
FORGE_DOMAIN_RE,
3232
FORGE_REF,
3333
LAST_SESSION_PARAM,
3434
LONG_POLLING,
@@ -222,8 +222,8 @@ export class BrowserPollConnection implements Transport {
222222
}
223223
if (
224224
typeof location !== 'undefined' &&
225-
location.href &&
226-
location.href.indexOf(FORGE_DOMAIN) !== -1
225+
location.hostname &&
226+
FORGE_DOMAIN_RE.test(location.hostname)
227227
) {
228228
urlParams[REFERER_PARAM] = FORGE_REF;
229229
}

packages/database/src/realtime/Constants.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export const REFERER_PARAM = 'r';
2525

2626
export const FORGE_REF = 'f';
2727

28-
export const FORGE_DOMAIN = 'firebaseio.com';
28+
// Matches console.firebase.google.com, firebase-console-*.corp.google.com and
29+
// firebase.corp.google.com
30+
export const FORGE_DOMAIN_RE = /(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/;
2931

3032
export const LAST_SESSION_PARAM = 'ls';
3133

packages/database/src/realtime/WebSocketConnection.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@
1616
*/
1717

1818
import { RepoInfo } from '../core/RepoInfo';
19-
import {
20-
assert,
21-
jsonEval,
22-
stringify,
23-
isNodeSdk
24-
} from '@firebase/util';
19+
import { assert, jsonEval, stringify, isNodeSdk } from '@firebase/util';
2520
import { logWrapper, splitStringBySize } from '../core/util/util';
2621
import { StatsManager } from '../core/stats/StatsManager';
2722
import {
28-
FORGE_DOMAIN,
23+
FORGE_DOMAIN_RE,
2924
FORGE_REF,
3025
LAST_SESSION_PARAM,
3126
PROTOCOL_VERSION,
@@ -121,8 +116,8 @@ export class WebSocketConnection implements Transport {
121116
if (
122117
!isNodeSdk() &&
123118
typeof location !== 'undefined' &&
124-
location.href &&
125-
location.href.indexOf(FORGE_DOMAIN) !== -1
119+
location.hostname &&
120+
FORGE_DOMAIN_RE.test(location.hostname)
126121
) {
127122
urlParams[REFERER_PARAM] = FORGE_REF;
128123
}

0 commit comments

Comments
 (0)