Skip to content

Commit 50abe6c

Browse files
Fix refFromUrl when used with emulator (#4199)
1 parent 34b4e30 commit 50abe6c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

.changeset/clever-kangaroos-hug.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/database": patch
3+
---
4+
5+
Fixes an issue that caused `refFromUrl()` to reject production database URLs when `useEmulator()` was used.

packages/database/src/api/Database.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class Database implements FirebaseService {
156156

157157
const repoInfo = parsedURL.repoInfo;
158158
if (
159-
!repoInfo.isCustomHost() &&
159+
!this.repo_.repoInfo_.isCustomHost() &&
160160
repoInfo.host !== this.repo_.repoInfo_.host
161161
) {
162162
fatal(

packages/database/test/database.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ describe('Database Tests', () => {
268268
});
269269

270270
it('refFromURL() validates domain', () => {
271-
const db = (firebase as any).database();
272-
expect(() => {
273-
const ref = db.refFromURL(
274-
'https://thisisnotarealfirebase.firebaseio.com/path/to/data'
275-
);
276-
}).to.throw(/does not match.*database/i);
271+
const db = (firebase as any)
272+
.app()
273+
.database('https://thisisreal.firebaseio.com');
274+
expect(() =>
275+
db.refFromURL('https://thisisnotreal.firebaseio.com/path/to/data')
276+
).to.throw(/does not match.*database/i);
277277
});
278278

279279
it('refFromURL() validates argument', () => {

0 commit comments

Comments
 (0)