mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: inefficient method of extracting url from text (#741)
* fix: inefficient method of extracting url from text This fixes the thumbnail error when submitting a Google Maps link. * fix: link preview with redirects
This commit is contained in:
@@ -54,7 +54,7 @@ export const getUrlInfo = async(
|
||||
|
||||
const info = await getLinkPreview(previewLink, {
|
||||
...opts.fetchOpts,
|
||||
followRedirects: 'manual',
|
||||
followRedirects: 'follow',
|
||||
handleRedirects: (baseURL: string, forwardedURL: string) => {
|
||||
const urlObj = new URL(baseURL)
|
||||
const forwardedURLObj = new URL(forwardedURL)
|
||||
|
||||
@@ -68,7 +68,7 @@ const ButtonType = proto.Message.ButtonsMessage.HeaderType
|
||||
* @returns the URL, eg. https://google.com
|
||||
*/
|
||||
export const extractUrlFromText = (text: string) => (
|
||||
!URL_EXCLUDE_REGEX.test(text) ? text.match(URL_REGEX)?.[0] : undefined
|
||||
text.split(' ').find(word => URL_REGEX.test(word) && !URL_EXCLUDE_REGEX.test(word)) || undefined
|
||||
)
|
||||
|
||||
export const generateLinkPreviewIfRequired = async(text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => {
|
||||
|
||||
Reference in New Issue
Block a user