Skip to content

Fix refFromUrl when used with emulator #4199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -246,12 +246,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