Skip to content

Commit ec63394

Browse files
Support storage.googleapis.com in refFromUrl
1 parent 4f1f303 commit ec63394

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/storage/src/implementation/location.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* object location.
2121
*/
2222
import * as errorsExports from './error';
23-
import { DEFAULT_HOST } from './constants';
2423

2524
/**
2625
* @struct
@@ -84,7 +83,7 @@ export class Location {
8483
loc.path_ = decodeURIComponent(loc.path);
8584
}
8685
const version = 'v[A-Za-z0-9_]+';
87-
const hostRegex = DEFAULT_HOST.replace(/[.]/g, '\\.');
86+
const hostRegex = "(?:firebase)?storage.googleapis.com";
8887
const httpRegex = new RegExp(
8988
`^https?://${hostRegex}/${version}/b/${bucketDomain}/o${path}`,
9089
'i'

packages/storage/test/service.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ describe('Firebase Storage > Service', () => {
182182
);
183183
assert.equal(ref.toString(), 'gs://mybucket/child/path/image.png');
184184
});
185+
it('Works with storage.googleapis.com URLs', () => {
186+
const ref = service.refFromURL(
187+
`http://storage.googleapis.com/v0/b/` +
188+
'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
189+
);
190+
assert.equal(ref.toString(), 'gs://mybucket/child/path/image.png');
191+
});
185192
});
186193
describe('Argument verification', () => {
187194
const service = new Service(

0 commit comments

Comments
 (0)