Skip to content

Commit

Permalink
Add a sanity check for useEmulator URL. (#3934)
Browse files Browse the repository at this point in the history
* Add a sanity check for useEmulator URL.

* Create early-elephants-learn.md

* Wrap line to keep under 100 chars.
  • Loading branch information
yuchenshi authored Oct 13, 2020
1 parent 00c963b commit 916770f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-elephants-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/auth": patch
---

Add a validation for useEmulator URL.
5 changes: 5 additions & 0 deletions packages/auth/src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ fireauth.Auth.prototype.useDeviceLanguage = function() {
fireauth.Auth.prototype.useEmulator = function(url) {
// Emulator config can only be set once.
if (!this.emulatorConfig_) {
if (!/^https?:\/\//.test(url)) {
throw new fireauth.AuthError(
fireauth.authenum.Error.ARGUMENT_ERROR,
'Emulator URL must start with a valid scheme (http:// or https://).');
}
// Emit a warning so dev knows we are now in test mode.
this.emitEmulatorWarning_();
// Persist the config.
Expand Down

0 comments on commit 916770f

Please sign in to comment.