Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sanity check for useEmulator URL. #3934

Merged
merged 3 commits into from Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/early-elephants-learn.md
@@ -0,0 +1,5 @@
---
"@firebase/auth": patch
---

Add a validation for useEmulator URL.
4 changes: 4 additions & 0 deletions packages/auth/src/auth.js
Expand Up @@ -299,6 +299,10 @@ 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://).');
yuchenshi marked this conversation as resolved.
Show resolved Hide resolved
}
// Emit a warning so dev knows we are now in test mode.
this.emitEmulatorWarning_();
// Persist the config.
Expand Down