Skip to content

Commit

Permalink
encoding string with encodeURIComponent to allow characters like '\n'…
Browse files Browse the repository at this point in the history
…(line break) or '&'
  • Loading branch information
Briuor committed Mar 14, 2020
1 parent 551f4b5 commit 4d77346
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function generateQRCode() {
async function sendTo(phone, message) {
try {
spinner.start("Sending Message\n");
message = encodeURIComponent(message);
await page.goto(`https://web.whatsapp.com/send?phone=${phone}&text=${message}`);
await page.waitForSelector("div#startup", { hidden: true, timeout: 60000 });
await page.waitForSelector('div[data-tab="1"]', { timeout: 60000 });
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wbm.start().then(async () => {
{ phone: '5535988841854', name: "Bruno", age: 21 },
{ phone: '5535988841854', name: "Bruno", age: 21 },
{ phone: '5535988841854', name: "Bruno", age: 21 }];
const message = 'hello {{name}} your age is {{age}}';
const message = 'hello {{name}} & your age is {{age}}';
await wbm.sendCustom(contacts, message);
});

Expand Down

0 comments on commit 4d77346

Please sign in to comment.