Skip to content

Commit 2e8e3d7

Browse files
committed
check localhost first
1 parent 1488424 commit 2e8e3d7

File tree

1 file changed

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

1 file changed

+6
-8
lines changed

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

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

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') {
177+
if (host.slice(0, colonInd).toLowerCase() === 'localhost') {
183178
domain = 'localhost';
184-
} else if (dotInd === colonInd) {
185-
return; // Not a valid URL.
186179
} else {
180+
let dotInd = host.indexOf('.');
181+
if (dotInd === -1) {
182+
return; // Not a valid URL.
183+
}
184+
const hostFirstPart = host.substring(0, dotInd);
187185
domain = host.substring(dotInd+1);
188186
// Normalize namespaces to lowercase to share storage / connection.
189187
subdomain = hostFirstPart.toLowerCase();

0 commit comments

Comments
 (0)