Skip to content

Commit 44ef7fc

Browse files
Addressing ESLint violation (Azure#22830)
* Fixing id encoding issues when using special characters for customers already on ComputeGateway * Update CHANGELOG.md * Update CHANGELOG.md * Fixing typos * Update cosmos-integration-public.yml * Update itemIdEncoding.spec.ts * Reformatting
1 parent ce35c33 commit 44ef7fc

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

sdk/cosmosdb/cosmos/src/common/helper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ export function isItemResourceValid(resource: { id?: string }, err: { message?:
224224
return false;
225225
}
226226

227-
if (resource.id.indexOf("/") !== -1 || resource.id.indexOf("\\") !== -1 || resource.id.indexOf("#") !== -1) {
227+
if (
228+
resource.id.indexOf("/") !== -1 ||
229+
resource.id.indexOf("\\") !== -1 ||
230+
resource.id.indexOf("#") !== -1
231+
) {
228232
err.message = "Id contains illegal chars.";
229233
return false;
230234
}
@@ -287,7 +291,7 @@ export function validateResourceId(resourceId: string): boolean {
287291
/**
288292
* @hidden
289293
*/
290-
export function validateItemResourceId(resourceId: string): boolean {
294+
export function validateItemResourceId(resourceId: string): boolean {
291295
// if resourceId is not a string or is empty throw an error
292296
if (typeof resourceId !== "string" || isStringNullOrEmpty(resourceId)) {
293297
throw new Error("Resource ID must be a string and cannot be undefined, null or empty");

sdk/cosmosdb/cosmos/test/public/functional/itemIdEncoding.spec.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import assert from "assert";
44
import { Suite } from "mocha";
55
import { Container, CosmosClient } from "../../../src";
6-
import { getTestContainer, removeAllDatabases, defaultClient, defaultComputeGatewayClient } from "../common/TestHelpers";
6+
import {
7+
getTestContainer,
8+
removeAllDatabases,
9+
defaultClient,
10+
defaultComputeGatewayClient,
11+
} from "../common/TestHelpers";
712

813
interface ItemPayload {
914
id?: string;
@@ -27,12 +32,11 @@ const createPayload = function (id: string): ItemPayload {
2732
};
2833
};
2934

30-
const executeTestCaseOnComputeGateway = async function (scenario: TestScenario) {
31-
return executeTestCase(scenario, true);
32-
}
33-
34-
const executeTestCase = async function (scenario: TestScenario, useComputeGateway: boolean = false) {
35-
const client: CosmosClient = useComputeGateway ? defaultComputeGatewayClient : defaultClient
35+
const executeTestCase = async function (
36+
scenario: TestScenario,
37+
useComputeGateway: boolean = false
38+
) {
39+
const client: CosmosClient = useComputeGateway ? defaultComputeGatewayClient : defaultClient;
3640
const container: Container = await getTestContainer(scenario.name, client, {
3741
partitionKey: {
3842
paths: ["/pk"],
@@ -109,6 +113,10 @@ const executeTestCase = async function (scenario: TestScenario, useComputeGatewa
109113
}
110114
};
111115

116+
const executeTestCaseOnComputeGateway = async function (scenario: TestScenario) {
117+
return executeTestCase(scenario, true);
118+
};
119+
112120
describe("Id encoding", function (this: Suite) {
113121
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
114122
beforeEach(async function () {

0 commit comments

Comments
 (0)