Skip to content

Commit e965bbd

Browse files
committed
Simplify refFromURL
1 parent 49ab776 commit e965bbd

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

packages/database/src/api/Database.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,14 @@ export class Database implements FirebaseService {
157157
validateUrl(apiName, 1, parsedURL);
158158

159159
const repoInfo = parsedURL.repoInfo;
160-
const expectedHost = this.repo_.originalHost;
161-
if (repoInfo.host !== expectedHost) {
160+
if (!repoInfo.isCustomHost() && repoInfo.host !== this.repo_.repoInfo_.host) {
162161
fatal(
163162
apiName +
164163
': Host name does not match the current database: ' +
165164
'(found ' +
166165
repoInfo.host +
167166
' but expected ' +
168-
expectedHost +
167+
this.repo_.repoInfo_.host+
169168
')'
170169
);
171170
}

packages/database/src/core/Repo.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ export class Repo {
5757
/** Key for uniquely identifying this repo, used in RepoManager */
5858
readonly key: string;
5959

60-
/** Record of the original host, which does not change even if useEmulator mutates the repo */
61-
readonly originalHost: string;
62-
6360
dataUpdateCount = 0;
6461
private infoSyncTree_: SyncTree;
6562
private serverSyncTree_: SyncTree;
@@ -93,7 +90,6 @@ export class Repo {
9390
) {
9491
// This key is intentionally not updated if RepoInfo is later changed or replaced
9592
this.key = this.repoInfo_.toURLString();
96-
this.originalHost = this.repoInfo_.host;
9793
}
9894

9995
start(): void {

packages/database/test/database.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ describe('Database Tests', () => {
229229
});
230230

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

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

0 commit comments

Comments
 (0)