@@ -75,23 +75,41 @@ export class Location {
75
75
}
76
76
}
77
77
const gsPath = '(/(.*))?$' ;
78
- const path = '(/([^?#]*).*)?$' ;
79
78
const gsRegex = new RegExp ( '^gs://' + bucketDomain + gsPath , 'i' ) ;
80
79
const gsIndices = { bucket : 1 , path : 3 } ;
81
80
82
81
function httpModify ( loc : Location ) : void {
83
82
loc . path_ = decodeURIComponent ( loc . path ) ;
84
83
}
85
84
const version = 'v[A-Za-z0-9_]+' ;
86
- const hostRegex = "(?:firebase)?storage.googleapis.com" ;
87
- const httpRegex = new RegExp (
88
- `^https?://${ hostRegex } /${ version } /b/${ bucketDomain } /o${ path } ` ,
85
+ const firebaseStorageHost = 'firebasestorage.googleapis.com' ;
86
+ const firebaseStoragePath = '(/([^?#]*).*)?$' ;
87
+ const firebaseStorageRegExp = new RegExp (
88
+ `^https?://${ firebaseStorageHost } /${ version } /b/${ bucketDomain } /o${ firebaseStoragePath } ` ,
89
89
'i'
90
90
) ;
91
- const httpIndices = { bucket : 1 , path : 3 } ;
91
+ const firebaseStorageIndices = { bucket : 1 , path : 3 } ;
92
+
93
+ const cloudStorageHost = 'storage.googleapis.com' ;
94
+ const cloudStoragePath = '([^?]*)' ;
95
+ const cloudStorageRegExp = new RegExp (
96
+ `^https?://${ cloudStorageHost } /${ bucketDomain } /${ cloudStoragePath } ` ,
97
+ 'i'
98
+ ) ;
99
+ const cloudStorageIndices = { bucket : 1 , path : 2 } ;
100
+
92
101
const groups = [
93
102
{ regex : gsRegex , indices : gsIndices , postModify : gsModify } ,
94
- { regex : httpRegex , indices : httpIndices , postModify : httpModify }
103
+ {
104
+ regex : firebaseStorageRegExp ,
105
+ indices : firebaseStorageIndices ,
106
+ postModify : httpModify
107
+ } ,
108
+ {
109
+ regex : cloudStorageRegExp ,
110
+ indices : cloudStorageIndices ,
111
+ postModify : httpModify
112
+ }
95
113
] ;
96
114
for ( let i = 0 ; i < groups . length ; i ++ ) {
97
115
const group = groups [ i ] ;
0 commit comments