WhatsApp: include numbers in contact cards

This commit is contained in:
Mahmoud Ibrahim
2026-01-10 01:26:21 +02:00
committed by Peter Steinberger
parent e311dc82e0
commit fd7450e5b9
3 changed files with 101 additions and 18 deletions

View File

@@ -32,7 +32,8 @@ export function parseVcard(vcard?: string): ParsedVcard {
continue;
}
if (baseKey === "TEL") {
phones.push(value);
const phone = normalizeVcardPhone(value);
if (phone) phones.push(phone);
}
}
return { name: nameFromFn ?? nameFromN, phones };
@@ -56,3 +57,12 @@ function cleanVcardValue(value: string): string {
function normalizeVcardName(value: string): string {
return value.replace(/;/g, " ").replace(/\s+/g, " ").trim();
}
function normalizeVcardPhone(value: string): string {
const trimmed = value.trim();
if (!trimmed) return "";
if (trimmed.toLowerCase().startsWith("tel:")) {
return trimmed.slice(4).trim();
}
return trimmed;
}