Skip to content

Commit

Permalink
Fix refFromUrl when used with emulator (#4199)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Jan 8, 2021
1 parent 34b4e30 commit 50abe6c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-kangaroos-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/database": patch
---

Fixes an issue that caused `refFromUrl()` to reject production database URLs when `useEmulator()` was used.
2 changes: 1 addition & 1 deletion packages/database/src/api/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class Database implements FirebaseService {

const repoInfo = parsedURL.repoInfo;
if (
!repoInfo.isCustomHost() &&
!this.repo_.repoInfo_.isCustomHost() &&
repoInfo.host !== this.repo_.repoInfo_.host
) {
fatal(
Expand Down
12 changes: 6 additions & 6 deletions packages/database/test/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ describe('Database Tests', () => {
});

it('refFromURL() validates domain', () => {
const db = (firebase as any).database();
expect(() => {
const ref = db.refFromURL(
'https://thisisnotarealfirebase.firebaseio.com/path/to/data'
);
}).to.throw(/does not match.*database/i);
const db = (firebase as any)
.app()
.database('https://thisisreal.firebaseio.com');
expect(() =>
db.refFromURL('https://thisisnotreal.firebaseio.com/path/to/data')
).to.throw(/does not match.*database/i);
});

it('refFromURL() validates argument', () => {
Expand Down

0 comments on commit 50abe6c

Please sign in to comment.