File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -178,8 +178,9 @@ export const parseDatabaseURL = function(
178
178
if ( hostWithoutPort . toLowerCase ( ) === 'localhost' ) {
179
179
domain = 'localhost' ;
180
180
} else if ( hostWithoutPort . split ( '.' ) . length <= 2 ) {
181
- domain = hostWithoutPort ; // Domain is at least 2 parts.
181
+ domain = hostWithoutPort ;
182
182
} else {
183
+ // Interpret the subdomain of a 3 or more component URL as the namespace name.
183
184
const dotInd = host . indexOf ( '.' ) ;
184
185
subdomain = host . substring ( 0 , dotInd ) . toLowerCase ( ) ;
185
186
domain = host . substring ( dotInd + 1 ) ;
Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ describe('Database Tests', () => {
80
80
) ;
81
81
} ) ;
82
82
83
+ it ( 'Can get database with localhost URL' , ( ) => {
84
+ const db = defaultApp . database ( 'http://localhost' ) ;
85
+ expect ( db ) . to . be . ok ;
86
+ expect ( db . ref ( ) . toString ( ) ) . to . equal ( 'https://localhost/' ) ;
87
+ } ) ;
88
+
83
89
it ( 'Can get database with localhost URL and port' , ( ) => {
84
90
const db = defaultApp . database ( 'http://localhost:80' ) ;
85
91
expect ( db ) . to . be . ok ;
@@ -92,9 +98,10 @@ describe('Database Tests', () => {
92
98
expect ( db . ref ( ) . toString ( ) ) . to . equal ( 'https://localhost/' ) ;
93
99
} ) ;
94
100
95
- it ( 'Can get database with localhost URL' , ( ) => {
96
- const db = defaultApp . database ( 'http://localhost ' ) ;
101
+ it ( 'Can get database with a upper case localhost URL and ns ' , ( ) => {
102
+ const db = defaultApp . database ( 'http://LOCALHOST?ns=foo ' ) ;
97
103
expect ( db ) . to . be . ok ;
104
+ expect ( db . repo_ . repoInfo_ . namespace ) . to . equal ( 'foo' ) ;
98
105
expect ( db . ref ( ) . toString ( ) ) . to . equal ( 'https://localhost/' ) ;
99
106
} ) ;
100
107
You can’t perform that action at this time.
0 commit comments