From 069d8966122097ceda20c225d6abf6fc3044b9fa Mon Sep 17 00:00:00 2001 From: valadaptive Date: Sun, 20 Jul 2025 00:32:32 -0400 Subject: [PATCH] Use charset=utf-8 for text and JSON mimetypes --- packages/sirv/index.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sirv/index.mjs b/packages/sirv/index.mjs index 3ad14d4..22eae25 100644 --- a/packages/sirv/index.mjs +++ b/packages/sirv/index.mjs @@ -101,7 +101,13 @@ function toHeaders(name, stats, isEtag) { let enc = ENCODING[name.slice(-3)]; let ctype = lookup(name.slice(0, enc && -3)) || ''; - if (ctype === 'text/html') ctype += ';charset=utf-8'; + if ( + ctype === 'application/json' || + ctype === 'application/manifest+json' || + ctype.startsWith('text/') + ) { + ctype += ';charset=utf-8'; + } let headers = { 'Content-Length': stats.size,