Skip to content

Commit 1a387ea

Browse files
committed
Fix host parsing
1 parent 739cbca commit 1a387ea

File tree

1 file changed

+5
-1
lines changed
  • packages/rules-unit-testing/src/api

1 file changed

+5
-1
lines changed

packages/rules-unit-testing/src/api/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ function getHubHost() {
429429
}
430430

431431
function parseHost(host: string): { hostname: string; port: number } {
432-
const u = new URL(host);
432+
const withProtocol = host.startsWith("http") ? host : `http://${host}`;
433+
const u = new URL(withProtocol);
433434
return {
434435
hostname: u.hostname,
435436
port: Number.parseInt(u.port, 10)
@@ -495,6 +496,9 @@ function initializeApp(
495496
);
496497
}
497498
if (databaseName) {
499+
const { hostname, port } = parseHost(getDatabaseHost());
500+
app.firestore().useEmulator(hostname, port);
501+
498502
// Toggle network connectivity to force a reauthentication attempt.
499503
// This mitigates a minor race condition where the client can send the
500504
// first database request before authenticating.

0 commit comments

Comments
 (0)