@@ -72,7 +72,7 @@ export const parseRepoInfo = function(
72
72
const parsedUrl = parseDatabaseURL ( dataURL ) ,
73
73
namespace = parsedUrl . namespace ;
74
74
75
- if ( parsedUrl . domain === 'firebase' ) {
75
+ if ( parsedUrl . domain === 'firebase.com ' ) {
76
76
fatal (
77
77
parsedUrl . host +
78
78
' is no longer supported. ' +
@@ -174,21 +174,18 @@ export const parseDatabaseURL = function(
174
174
colonInd = dataURL . length ;
175
175
}
176
176
177
- const parts = host . split ( '.' ) ;
178
- if ( parts . length === 4 ) {
179
- domain = parts [ 1 ] + "." + parts [ 2 ] ;
180
- subdomain = parts [ 0 ] . toLowerCase ( ) ;
181
- namespace = subdomain ;
182
- } else if ( parts . length === 3 ) {
177
+ let dotInd = host . indexOf ( '.' ) ;
178
+ if ( dotInd === - 1 ) {
179
+ dotInd = colonInd ;
180
+ }
181
+ const hostFirstPart = host . substring ( 0 , dotInd ) ;
182
+ if ( hostFirstPart . toLowerCase ( ) === 'localhost' ) {
183
+ domain = 'localhost' ;
184
+ } else {
185
+ domain = host . substring ( dotInd + 1 ) ;
183
186
// Normalize namespaces to lowercase to share storage / connection.
184
- domain = parts [ 1 ] ;
185
- subdomain = parts [ 0 ] . toLowerCase ( ) ;
186
- // We interpret the subdomain of a 3 component URL as the namespace name.
187
+ subdomain = hostFirstPart . toLowerCase ( ) ;
187
188
namespace = subdomain ;
188
- } else if ( parts . length === 2 ) {
189
- domain = parts [ 0 ] ;
190
- } else if ( parts [ 0 ] . slice ( 0 , colonInd ) . toLowerCase ( ) === 'localhost' ) {
191
- domain = 'localhost' ;
192
189
}
193
190
// Always treat the value of the `ns` as the namespace name if it is present.
194
191
if ( 'ns' in queryParams ) {
0 commit comments