mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-19 03:59:16 +00:00
fix countrycode and formatted number functions, add tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0];
|
||||
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
||||
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
||||
window.Store.NumberInfo = window.mR.findModule('formatNumber')[0];
|
||||
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
|
||||
window.Store.Cmd = window.mR.findModule('Cmd')[0].default;
|
||||
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
||||
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
||||
|
||||
Reference in New Issue
Block a user