Fix connection string renew token pane (#136)

* Fix IcM issue + conn string parsing

* format code

* Undo fix for IcM issue
This commit is contained in:
Vignesh Rangaishenvi 2020-08-06 16:15:31 -07:00 committed by GitHub
parent 0011007d5f
commit 08ee86ecf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -14,7 +14,10 @@ export class BackendEndpoints {
} }
export class EndpointsRegex { export class EndpointsRegex {
public static readonly cassandra = "AccountEndpoint=(.*).cassandra.cosmosdb.azure.com"; public static readonly cassandra = [
"AccountEndpoint=(.*).cassandra.cosmosdb.azure.com",
"HostName=(.*).cassandra.cosmos.azure.com"
];
public static readonly mongo = "mongodb://.*:(.*)@(.*).documents.azure.com"; public static readonly mongo = "mongodb://.*:(.*)@(.*).documents.azure.com";
public static readonly mongoCompute = "mongodb://.*:(.*)@(.*).mongo.cosmos.azure.com"; public static readonly mongoCompute = "mongodb://.*:(.*)@(.*).mongo.cosmos.azure.com";
public static readonly sql = "AccountEndpoint=https://(.*).documents.azure.com"; public static readonly sql = "AccountEndpoint=https://(.*).documents.azure.com";

View File

@ -20,9 +20,13 @@ export class ConnectionStringParser {
const matches: string[] = connectionStringPart.match(Constants.EndpointsRegex.mongoCompute); const matches: string[] = connectionStringPart.match(Constants.EndpointsRegex.mongoCompute);
accessInput.accountName = matches && matches.length > 1 && matches[2]; accessInput.accountName = matches && matches.length > 1 && matches[2];
accessInput.apiKind = DataModels.ApiKind.MongoDBCompute; accessInput.apiKind = DataModels.ApiKind.MongoDBCompute;
} else if (RegExp(Constants.EndpointsRegex.cassandra).test(connectionStringPart)) { } else if (Constants.EndpointsRegex.cassandra.some(regex => RegExp(regex).test(connectionStringPart))) {
accessInput.accountName = connectionStringPart.match(Constants.EndpointsRegex.cassandra)[1]; Constants.EndpointsRegex.cassandra.forEach(regex => {
if (RegExp(regex).test(connectionStringPart)) {
accessInput.accountName = connectionStringPart.match(regex)[1];
accessInput.apiKind = DataModels.ApiKind.Cassandra; accessInput.apiKind = DataModels.ApiKind.Cassandra;
}
});
} else if (RegExp(Constants.EndpointsRegex.table).test(connectionStringPart)) { } else if (RegExp(Constants.EndpointsRegex.table).test(connectionStringPart)) {
accessInput.accountName = connectionStringPart.match(Constants.EndpointsRegex.table)[1]; accessInput.accountName = connectionStringPart.match(Constants.EndpointsRegex.table)[1];
accessInput.apiKind = DataModels.ApiKind.Table; accessInput.apiKind = DataModels.ApiKind.Table;