Skip to content

Commit 98eb1ce

Browse files
fix(auth): allow emulator hostnames to contain hyphens (#6141)
1 parent ca50d6e commit 98eb1ce

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/auth/__tests__/auth.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ describe('Auth', function () {
4242
const bar = auth().useEmulator('http://127.0.0.1:9099');
4343
expect(bar).toEqual(['10.0.2.2', 9099]);
4444
});
45+
46+
it('useEmulator allows hyphens in the hostname', function () {
47+
const result = auth().useEmulator('http://my-host:9099');
48+
expect(result).toEqual(['my-host', 9099]);
49+
});
4550
});
4651

4752
describe('tenantId', function () {

packages/auth/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class FirebaseAuthModule extends FirebaseModule {
381381
}
382382

383383
// Native calls take the host and port split out
384-
const hostPortRegex = /^http:\/\/([\w\d.]+):(\d+)$/;
384+
const hostPortRegex = /^http:\/\/([\w\d-.]+):(\d+)$/;
385385
const urlMatches = _url.match(hostPortRegex);
386386
if (!urlMatches) {
387387
throw new Error('firebase.auth().useEmulator() unable to parse host and port from URL');

0 commit comments

Comments
 (0)