Skip to content

Commit

Permalink
Simplify refFromURL
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed Oct 20, 2020
1 parent 49ab776 commit e965bbd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
5 changes: 2 additions & 3 deletions packages/database/src/api/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,14 @@ export class Database implements FirebaseService {
validateUrl(apiName, 1, parsedURL);

const repoInfo = parsedURL.repoInfo;
const expectedHost = this.repo_.originalHost;
if (repoInfo.host !== expectedHost) {
if (!repoInfo.isCustomHost() && repoInfo.host !== this.repo_.repoInfo_.host) {
fatal(
apiName +
': Host name does not match the current database: ' +
'(found ' +
repoInfo.host +
' but expected ' +
expectedHost +
this.repo_.repoInfo_.host+
')'
);
}
Expand Down
4 changes: 0 additions & 4 deletions packages/database/src/core/Repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export class Repo {
/** Key for uniquely identifying this repo, used in RepoManager */
readonly key: string;

/** Record of the original host, which does not change even if useEmulator mutates the repo */
readonly originalHost: string;

dataUpdateCount = 0;
private infoSyncTree_: SyncTree;
private serverSyncTree_: SyncTree;
Expand Down Expand Up @@ -93,7 +90,6 @@ export class Repo {
) {
// This key is intentionally not updated if RepoInfo is later changed or replaced
this.key = this.repoInfo_.toURLString();
this.originalHost = this.repoInfo_.host;
}

start(): void {
Expand Down
4 changes: 2 additions & 2 deletions packages/database/test/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ describe('Database Tests', () => {
});

it('ref() validates project', () => {
const db1 = defaultApp.database('http://bar.foo.com');
const db2 = defaultApp.database('http://foo.bar.com');
const db1 = defaultApp.database('http://bar.firebaseio.com');
const db2 = defaultApp.database('http://foo.firebaseio.com');

const ref1 = db1.ref('child');

Expand Down

0 comments on commit e965bbd

Please sign in to comment.