mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-09-19 09:02:41 +01:00
Drop unused mongodb:// branch from endpoint host extraction
This commit is contained in:
@@ -64,8 +64,9 @@ export const validateDirectConnectionStringConnectivity = async (
|
||||
return t(Keys.connectExplorer.errors.connectivityInvalid);
|
||||
}
|
||||
|
||||
// Configure the client the same way the Data Explorer will, then issue a lightweight authenticated
|
||||
// request. The Cosmos client signs locally with the master key and routes through the same proxy.
|
||||
// The Cosmos client reads its connection settings from userContext, so write the master key and
|
||||
// endpoint there. Then we issue a lightweight authenticated read to confirm the
|
||||
// credentials work.
|
||||
updateUserContext({
|
||||
authType: AuthType.ConnectionString,
|
||||
masterKey,
|
||||
|
||||
@@ -45,9 +45,7 @@ export function parseConnectionString(connectionString: string): AccessInputMeta
|
||||
}
|
||||
|
||||
// For the APIs that log in directly through the Cosmos client (SQL, Tables, Gremlin), derive the
|
||||
// endpoints client-side instead of Portal Backend's accessinputmetadata call. Tables
|
||||
// connection strings only carry the table endpoint, so the document endpoint is always constructed
|
||||
// from the account name. Gremlin also needs its graph endpoint for websocket queries.
|
||||
// endpoints client-side instead of Portal Backend's accessinputmetadata call.
|
||||
if (accessInput.accountName) {
|
||||
if (
|
||||
accessInput.apiKind === ApiKind.SQL ||
|
||||
|
||||
@@ -55,8 +55,7 @@ export function extractAccountKeyFromConnectionString(connectionString: string):
|
||||
}
|
||||
|
||||
// SQL, Tables, and Gremlin can sign data-plane requests client-side with the account key, so they do
|
||||
// not need the Portal Backend proxy for connection-string login. Mongo and Cassandra still require the
|
||||
// proxy because they use wire protocols the browser cannot speak directly.
|
||||
// not need the Portal Backend proxy for connection-string login. Mongo and Cassandra still require the proxy.
|
||||
export function isDirectConnectionStringLoginApi(apiKind: ApiKind): boolean {
|
||||
return apiKind === ApiKind.SQL || apiKind === ApiKind.Table || apiKind === ApiKind.Graph;
|
||||
}
|
||||
@@ -86,19 +85,11 @@ function extractHostToken(value: string, startIndex: number): string {
|
||||
}
|
||||
|
||||
// Extracts the endpoint host from a connection string, mirroring ExtractEndpointHost in the Portal
|
||||
// Backend. Handles AccountEndpoint/TableEndpoint (URI or bare host), HostName, and mongodb:// segments.
|
||||
// Backend. Handles AccountEndpoint/TableEndpoint (URI or bare host) and HostName.
|
||||
export function extractEndpointHostFromConnectionString(connectionString: string): string | undefined {
|
||||
for (const part of connectionString.split(";")) {
|
||||
const trimmed = part.trim();
|
||||
|
||||
if (trimmed.toLowerCase().startsWith("mongodb://")) {
|
||||
const atIndex = trimmed.indexOf("@");
|
||||
if (atIndex >= 0 && atIndex < trimmed.length - 1) {
|
||||
return extractHostToken(trimmed, atIndex + 1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const equalsIndex = trimmed.indexOf("=");
|
||||
if (equalsIndex < 0 || equalsIndex === trimmed.length - 1) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user