fix countrycode and formatted number functions, add tests

This commit is contained in:
Pedro Lopez
2021-10-29 23:41:49 -04:00
parent 97a1d399ee
commit c434e04e41
3 changed files with 23 additions and 4 deletions

View File

@@ -857,9 +857,10 @@ class Client extends EventEmitter {
*/
async getFormattedNumber(number) {
if(!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
if(!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
return await this.pupPage.evaluate(async numberId => {
return window.NumberInfo.formattedPhoneNumber(numberId);
return window.Store.NumberInfo.formattedPhoneNumber(numberId);
}, number);
}
@@ -872,7 +873,7 @@ class Client extends EventEmitter {
number = number.replace(' ', '').replace('+', '').replace('@c.us', '');
return await this.pupPage.evaluate(async numberId => {
return window.NumberInfo.findCC(numberId);
return window.Store.NumberInfo.findCC(numberId);
}, number);
}