Skip to content

Commit 916770f

Browse files
authored
Add a sanity check for useEmulator URL. (#3934)
* Add a sanity check for useEmulator URL. * Create early-elephants-learn.md * Wrap line to keep under 100 chars.
1 parent 00c963b commit 916770f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/early-elephants-learn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/auth": patch
3+
---
4+
5+
Add a validation for useEmulator URL.

packages/auth/src/auth.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ fireauth.Auth.prototype.useDeviceLanguage = function() {
299299
fireauth.Auth.prototype.useEmulator = function(url) {
300300
// Emulator config can only be set once.
301301
if (!this.emulatorConfig_) {
302+
if (!/^https?:\/\//.test(url)) {
303+
throw new fireauth.AuthError(
304+
fireauth.authenum.Error.ARGUMENT_ERROR,
305+
'Emulator URL must start with a valid scheme (http:// or https://).');
306+
}
302307
// Emit a warning so dev knows we are now in test mode.
303308
this.emitEmulatorWarning_();
304309
// Persist the config.

0 commit comments

Comments
 (0)