@firebase/util 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -691,8 +691,20 @@ class Deferred {
691
691
  * Checks whether host is a cloud workstation or not.
692
692
  * @public
693
693
  */
694
- function isCloudWorkstation(host) {
695
- return host.endsWith('.cloudworkstations.dev');
694
+ function isCloudWorkstation(url) {
695
+ // `isCloudWorkstation` is called without protocol in certain connect*Emulator functions
696
+ // In HTTP request builders, it's called with the protocol.
697
+ // If called with protocol prefix, it's a valid URL, so we extract the hostname
698
+ // If called without, we assume the string is the hostname.
699
+ try {
700
+ const host = url.startsWith('http://') || url.startsWith('https://')
701
+ ? new URL(url).hostname
702
+ : url;
703
+ return host.endsWith('.cloudworkstations.dev');
704
+ }
705
+ catch (_a) {
706
+ return false;
707
+ }
696
708
  }
697
709
  /**
698
710
  * Makes a fetch request to the given server.