fix: address review — pin .xml alias in MIME_BY_EXT, hoist fallback above condition

- Pin '.xml': 'text/xml' in MIME_BY_EXT overrides to prevent
  application/xml from overwriting text/xml in the reversed map
- Move mediaType ??= fallback above the if-guard in send-api.ts
  for clarity (avoids side-effect assignment inside condition)
This commit is contained in:
Yosi Taguri
2026-03-21 12:24:09 +01:00
committed by Marcus Castro
parent 5661bcebd1
commit a1eae4d7ac
2 changed files with 3 additions and 1 deletions

View File

@@ -34,7 +34,8 @@ export function createWebSendApi(params: {
): Promise<{ messageId: string }> => {
const jid = toWhatsappJid(to);
let payload: AnyMessageContent;
if (mediaBuffer && (mediaType ??= "application/octet-stream")) {
mediaType ??= "application/octet-stream";
if (mediaBuffer && mediaType) {
if (mediaType.startsWith("image/")) {
payload = {
image: mediaBuffer,

View File

@@ -48,6 +48,7 @@ const MIME_BY_EXT: Record<string, string> = {
".jpeg": "image/jpeg",
".js": "text/javascript",
".htm": "text/html",
".xml": "text/xml", // pin text/xml as canonical (application/xml also maps to .xml in EXT_BY_MIME)
};
const AUDIO_FILE_EXTENSIONS = new Set([