Removing trailing ; from resource token which is incompatible with v2 tokens (#1962)

* Removing trailing ; from resource token which is incompatible with v2 tokens

* Adding check in case resourceToken is undefined

* Fixing unit tests
This commit is contained in:
vchske 2024-09-09 12:04:16 -07:00 committed by GitHub
parent 50c47a82d6
commit d75553a94d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -11,7 +11,7 @@ describe("parseResourceTokenConnectionString", () => {
collectionId: "fakeCollectionId",
databaseId: "fakeDatabaseId",
partitionKey: undefined,
resourceToken: "type=resource&ver=1&sig=2dIP+CdIfT1ScwHWdv5GGw==;fakeToken;",
resourceToken: "type=resource&ver=1&sig=2dIP+CdIfT1ScwHWdv5GGw==;fakeToken",
});
});
@ -25,7 +25,7 @@ describe("parseResourceTokenConnectionString", () => {
collectionId: "fakeCollectionId",
databaseId: "fakeDatabaseId",
partitionKey: "fakePartitionKey",
resourceToken: "type=resource&ver=1&sig=2dIP+CdIfT1ScwHWdv5GGw==;fakeToken;",
resourceToken: "type=resource&ver=1&sig=2dIP+CdIfT1ScwHWdv5GGw==;fakeToken",
});
});
});

View File

@ -30,6 +30,10 @@ export function parseResourceTokenConnectionString(connectionString: string): Pa
}
});
if (resourceToken && resourceToken.endsWith(";")) {
resourceToken = resourceToken.substring(0, resourceToken.length - 1);
}
return {
accountEndpoint,
collectionId,