From da26cf52856bc785292557bae51e0c07362242a1 Mon Sep 17 00:00:00 2001 From: Claudemir Todo Bom Date: Sat, 1 Mar 2025 13:15:33 -0300 Subject: [PATCH] Fix link preview being generated for email addresses (#1231) * link-preview: only match https urls without auth info * fix regex to find url on strings - fix #1230 --- src/Defaults/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Defaults/index.ts b/src/Defaults/index.ts index 62bcecb..c72c213 100644 --- a/src/Defaults/index.ts +++ b/src/Defaults/index.ts @@ -21,7 +21,7 @@ export const NOISE_WA_HEADER = Buffer.from( [ 87, 65, 6, DICT_VERSION ] ) // last is "DICT_VERSION" /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */ -export const URL_REGEX = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/ +export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g export const WA_CERT_DETAILS = { SERIAL: 0,