mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
* Revert "fix: inefficient method of extracting url from text (#741)"
This reverts commit f5c1affc4d.
* fix: link preview should follow redirects
* fix: allow link preview of URLs with @ sign
---------
Co-authored-by: Ezequiel Moraes <ezequielmoraesdev@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { randomBytes } from 'crypto'
|
||||
import { promises as fs } from 'fs'
|
||||
import { Logger } from 'pino'
|
||||
import { proto } from '../../WAProto'
|
||||
import { MEDIA_KEYS, URL_EXCLUDE_REGEX, URL_REGEX, WA_DEFAULT_EPHEMERAL } from '../Defaults'
|
||||
import { MEDIA_KEYS, URL_REGEX, WA_DEFAULT_EPHEMERAL } from '../Defaults'
|
||||
import {
|
||||
AnyMediaMessageContent,
|
||||
AnyMessageContent,
|
||||
@@ -68,9 +68,7 @@ const ButtonType = proto.Message.ButtonsMessage.HeaderType
|
||||
* @param text eg. hello https://google.com
|
||||
* @returns the URL, eg. https://google.com
|
||||
*/
|
||||
export const extractUrlFromText = (text: string) => (
|
||||
text.split(' ').find(word => URL_REGEX.test(word) && !URL_EXCLUDE_REGEX.test(word)) || undefined
|
||||
)
|
||||
export const extractUrlFromText = (text: string) => text.match(URL_REGEX)?.[0]
|
||||
|
||||
export const generateLinkPreviewIfRequired = async(text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => {
|
||||
const url = extractUrlFromText(text)
|
||||
|
||||
Reference in New Issue
Block a user