@@ -51,13 +51,10 @@ export class Location {
51
51
return '/b/' + encode ( this . bucket ) + '/o' ;
52
52
}
53
53
54
- static makeFromBucketSpec (
55
- bucketString : string ,
56
- customHost ?: string
57
- ) : Location {
54
+ static makeFromBucketSpec ( bucketString : string , host : string ) : Location {
58
55
let bucketLocation ;
59
56
try {
60
- bucketLocation = Location . makeFromUrl ( bucketString , customHost ) ;
57
+ bucketLocation = Location . makeFromUrl ( bucketString , host ) ;
61
58
} catch ( e ) {
62
59
// Not valid URL, use as-is. This lets you put bare bucket names in
63
60
// config.
@@ -70,7 +67,7 @@ export class Location {
70
67
}
71
68
}
72
69
73
- static makeFromUrl ( url : string , customHost ? : string ) : Location {
70
+ static makeFromUrl ( url : string , host : string ) : Location {
74
71
let location : Location | null = null ;
75
72
const bucketDomain = '([A-Za-z0-9.\\-_]+)' ;
76
73
@@ -87,10 +84,7 @@ export class Location {
87
84
loc . path_ = decodeURIComponent ( loc . path ) ;
88
85
}
89
86
const version = 'v[A-Za-z0-9_]+' ;
90
- const firebaseStorageHost = ( customHost ?? DEFAULT_HOST ) . replace (
91
- / [ . ] / g,
92
- '\\.'
93
- ) ;
87
+ const firebaseStorageHost = host . replace ( / [ . ] / g, '\\.' ) ;
94
88
const firebaseStoragePath = '(/([^?#]*).*)?$' ;
95
89
const firebaseStorageRegExp = new RegExp (
96
90
`^https?://${ firebaseStorageHost } /${ version } /b/${ bucketDomain } /o${ firebaseStoragePath } ` ,
@@ -99,7 +93,9 @@ export class Location {
99
93
const firebaseStorageIndices = { bucket : 1 , path : 3 } ;
100
94
101
95
const cloudStorageHost =
102
- customHost ?? '(?:storage.googleapis.com|storage.cloud.google.com)' ;
96
+ host === DEFAULT_HOST
97
+ ? '(?:storage.googleapis.com|storage.cloud.google.com)'
98
+ : host ;
103
99
const cloudStoragePath = '([^?#]*)' ;
104
100
const cloudStorageRegExp = new RegExp (
105
101
`^https?://${ cloudStorageHost } /${ bucketDomain } /${ cloudStoragePath } ` ,
0 commit comments