mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Preview link fix (#1548)
* Preview link fix * Preview link refactor * Deleted empty line * Redundant unnecessary changes * Added checker for http/https prefix in link Co-authored-by: Ilya Borodin <ilya.borodin@botconversa.com.br>
This commit is contained in:
@@ -248,9 +248,10 @@ export const generateWAMessageContent = async(
|
||||
const extContent = { text: message.text } as WATextMessage
|
||||
|
||||
let urlInfo = message.linkPreview
|
||||
if(!urlInfo && !!options.getUrlInfo && message.text.match(URL_REGEX)) {
|
||||
const matchedUrls = message.text.match(URL_REGEX)
|
||||
if(!urlInfo && !!options.getUrlInfo && matchedUrls) {
|
||||
try {
|
||||
urlInfo = await options.getUrlInfo(message.text)
|
||||
urlInfo = await options.getUrlInfo(matchedUrls[0])
|
||||
} catch(error) { // ignore if fails
|
||||
options.logger?.warn({ trace: error.stack }, 'url generation failed')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user