Skip to content

Commit

Permalink
fix(auth): allow emulator hostnames to contain hyphens (#6141)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramid-scheme-ceo authored Mar 23, 2022
1 parent ca50d6e commit 98eb1ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/auth/__tests__/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ describe('Auth', function () {
const bar = auth().useEmulator('http://127.0.0.1:9099');
expect(bar).toEqual(['10.0.2.2', 9099]);
});

it('useEmulator allows hyphens in the hostname', function () {
const result = auth().useEmulator('http://my-host:9099');
expect(result).toEqual(['my-host', 9099]);
});
});

describe('tenantId', function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class FirebaseAuthModule extends FirebaseModule {
}

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

1 comment on commit 98eb1ce

@vercel
Copy link

@vercel vercel bot commented on 98eb1ce Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.