Skip to content

Commit 96d3ec2

Browse files
committed
fix: avoid corrupting URLs with query strings
1 parent 3960624 commit 96d3ec2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,7 +2504,9 @@ export class BaileysStartupService extends ChannelStartupService {
25042504
imageBuffer = Buffer.from(base64Data, 'base64');
25052505
} else {
25062506
const timestamp = new Date().getTime();
2507-
const url = `${image}?timestamp=${timestamp}`;
2507+
const parsedURL = new URL(image);
2508+
parsedURL.searchParams.set('timestamp', timestamp.toString());
2509+
const url = parsedURL.toString();
25082510

25092511
let config: any = { responseType: 'arraybuffer' };
25102512

@@ -2725,7 +2727,9 @@ export class BaileysStartupService extends ChannelStartupService {
27252727

27262728
if (isURL(audio)) {
27272729
const timestamp = new Date().getTime();
2728-
const url = `${audio}?timestamp=${timestamp}`;
2730+
const parsedURL = new URL(audio);
2731+
parsedURL.searchParams.set('timestamp', timestamp.toString());
2732+
const url = parsedURL.toString();
27292733

27302734
const config: any = { responseType: 'stream' };
27312735

@@ -3591,7 +3595,9 @@ export class BaileysStartupService extends ChannelStartupService {
35913595
let pic: WAMediaUpload;
35923596
if (isURL(picture)) {
35933597
const timestamp = new Date().getTime();
3594-
const url = `${picture}?timestamp=${timestamp}`;
3598+
const parsedURL = new URL(picture);
3599+
parsedURL.searchParams.set('timestamp', timestamp.toString());
3600+
const url = parsedURL.toString();
35953601

35963602
let config: any = { responseType: 'arraybuffer' };
35973603

@@ -3873,7 +3879,9 @@ export class BaileysStartupService extends ChannelStartupService {
38733879
let pic: WAMediaUpload;
38743880
if (isURL(picture.image)) {
38753881
const timestamp = new Date().getTime();
3876-
const url = `${picture.image}?timestamp=${timestamp}`;
3882+
const parsedURL = new URL(picture.image);
3883+
parsedURL.searchParams.set('timestamp', timestamp.toString());
3884+
const url = parsedURL.toString();
38773885

38783886
let config: any = { responseType: 'arraybuffer' };
38793887

0 commit comments

Comments
 (0)