Skip to content

Commit c965bdd

Browse files
committed
pr feedback: escape backslash & update comments
1 parent 7e2ddb0 commit c965bdd

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/billing-accounts/billing-accounts.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class BillingAccountsController {
106106
type: Number,
107107
})
108108
async listByUserIds(@Param("userId", ParseIntPipe) userId: number) {
109-
return await this.service.listByUserId(userId);
109+
return this.service.listByUserId(userId);
110110
}
111111

112112
@Get(":billingAccountId")

src/billing-accounts/billing-accounts.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ export class BillingAccountsService {
1919

2020
/**
2121
* List billing accounts one or more user IDs have access to (via Salesforce resource object).
22-
* Accepts a single userId (string) or an array of userId strings.
22+
* Accepts a single userId (number) or an array of userId strings.
2323
*/
2424
async listByUserId(userId: number) {
2525
const { accessToken, instanceUrl } = await this.salesforce.authenticate();
2626

27-
// escape single quotes and build IN clause
28-
const escaped = `'${String(userId).replace(/'/g, "\\'")}'`;
27+
// escape backslashes and single quotes and build IN clause
28+
const escaped = `'${String(userId).replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
2929
const nameField =
3030
process.env.SFDC_BILLING_ACCOUNT_NAME_FIELD || "Billing_Account_name__c";
3131
const sql = `SELECT Topcoder_Billing_Account__r.Id, Topcoder_Billing_Account__r.TopCoder_Billing_Account_Id__c, Topcoder_Billing_Account__r.${nameField}, Topcoder_Billing_Account__r.Start_Date__c, Topcoder_Billing_Account__r.End_Date__c FROM Topcoder_Billing_Account_Resource__c tbar WHERE Topcoder_Billing_Account__r.Active__c=true AND UserID__c = ${escaped}`;

0 commit comments

Comments
 (0)