wa.me URLs incorrectly resolved to api.whatsapp.com in link previews
Problem When sending a text message containing a wa.me URL, the library's link preview functionality transforms the URL to api.whatsapp.com by following redirects. This behavior results in an incorrect preview display where the "Start chatting" button/text doesn't appear in the message.
Expected Behavior wa.me URLs should be preserved in their original format for link previews, as they represent WhatsApp's official short link format intended for user-facing contexts.
Current Behavior
With TextPreviewSetting.ENABLED_WITH_INFERENCE
Input: wa.me/[number]
Preview displays: api.whatsapp.com/[...]
With TextPreviewSetting.ENABLED, the URL is kept in the text, but changed in matchedText and canonicalUrl.
{
"message":{
"textMessage":{
"text":"test https://api.whatsapp.com/send/?phone=11234567890&text&type=phone_number&app_absent=0",
"matchedText":"https://api.whatsapp.com/send/?phone=11234567890&text&type=phone_number&app_absent=0",
"canonicalUrl":"https://api.whatsapp.com/send/?phone=11234567890&text&type=phone_number&app_absent=0",
"description":"WhatsApp Messenger: More than 2 billion people\n in over 180 countries use WhatsApp to stay in touch with friends and\n family, anytime and anywhere. WhatsApp is free and offers simple, secure,\n reliable messaging and calling, available on phones all over the world.",
"title":"Share on WhatsApp"
}
}
}
Suggested Solution The library should recognize wa.me URLs as a special case and preserve them in both text, matchedText and canonicalUrl fields.
Alternatively, a more general solution would be to always preserve the original URLs in text, matchedText and canonicalUrl, only following redirects internally to generate the preview content. This would maintain the user's intended URL display while still fetching accurate preview data.