Skip to content

Commit b68d8b1

Browse files
committed
Updated firebase/util to check for hostname
1 parent 4e61b20 commit b68d8b1

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.changeset/brown-pens-confess.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
"@firebase/storage": patch
3+
"@firebase/util": patch
34
---
45

56
Fixed issue where Storage on Firebase Studio throws CORS errors.

common/api-review/util.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export function isBrowserExtension(): boolean;
270270
export function isCloudflareWorker(): boolean;
271271

272272
// @public
273-
export function isCloudWorkstation(host: string): boolean;
273+
export function isCloudWorkstation(url: string): boolean;
274274

275275
// Warning: (ae-missing-release-tag) "isElectron" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
276276
//

packages/storage/src/platform/browser/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ abstract class XhrConnection<T extends ConnectionType>
7070
if (this.sent_) {
7171
throw internalError('cannot .send() more than once');
7272
}
73-
if (isCloudWorkstation(new URL(url).hostname) && isUsingEmulator) {
73+
if (isCloudWorkstation(url) && isUsingEmulator) {
7474
this.xhr_.withCredentials = true;
7575
}
7676
this.sent_ = true;

packages/util/src/url.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
* Checks whether host is a cloud workstation or not.
2020
* @public
2121
*/
22-
export function isCloudWorkstation(host: string): boolean {
22+
export function isCloudWorkstation(url: string): boolean {
23+
const host =
24+
url.startsWith('http://') || url.startsWith('https://')
25+
? new URL(url).hostname
26+
: url;
2327
return host.endsWith('.cloudworkstations.dev');
2428
}
2529

0 commit comments

Comments
 (0)