Skip to content

Commit 86e50b9

Browse files
committed
at least 2
1 parent 92dc48b commit 86e50b9

File tree

1 file changed

+8
-7
lines changed
  • packages/database/src/core/util/libs

1 file changed

+8
-7
lines changed

packages/database/src/core/util/libs/parser.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,17 @@ export const parseDatabaseURL = function(
174174
colonInd = dataURL.length;
175175
}
176176

177-
if (host.slice(0, colonInd).toLowerCase() === 'localhost') {
177+
const hostWithoutPort = host.slice(0, colonInd);
178+
if (hostWithoutPort.toLowerCase() === 'localhost') {
178179
domain = 'localhost';
180+
} else if (hostWithoutPort.split('.').length <= 2) {
181+
domain = hostWithoutPort; // Domain is at least 2 parts.
179182
} else {
180183
const dotInd = host.indexOf('.');
181-
if (dotInd !== -1) {
182-
// Normalize namespaces to lowercase to share storage / connection.
183-
subdomain = host.substring(0, dotInd).toLowerCase();
184-
namespace = subdomain;
185-
domain = host.substring(dotInd + 1);
186-
}
184+
domain = host.substring(dotInd + 1);
185+
subdomain = host.substring(0, dotInd).toLowerCase();
186+
// Normalize namespaces to lowercase to share storage / connection.
187+
namespace = subdomain;
187188
}
188189
// Always treat the value of the `ns` as the namespace name if it is present.
189190
if ('ns' in queryParams) {

0 commit comments

Comments
 (0)