amalgm 0.1.97 → 0.1.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -317,6 +317,18 @@ function inlineFilename(targetPath) {
|
|
|
317
317
|
return path.basename(targetPath).replace(/["\\\r\n]/g, '_') || 'file';
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
function contentDispositionInline(targetPath) {
|
|
321
|
+
const name = inlineFilename(targetPath);
|
|
322
|
+
// Header values must be ISO-8859-1; non-ASCII names (e.g. the narrow
|
|
323
|
+
// no-break space in macOS screenshot names) make res.writeHead throw.
|
|
324
|
+
// ASCII fallback plus RFC 5987 filename* carries the real name.
|
|
325
|
+
const asciiFallback = name.replace(/[^\x20-\x7e]/g, '_');
|
|
326
|
+
if (asciiFallback === name) {
|
|
327
|
+
return `inline; filename="${name}"`;
|
|
328
|
+
}
|
|
329
|
+
return `inline; filename="${asciiFallback}"; filename*=UTF-8''${encodeURIComponent(name)}`;
|
|
330
|
+
}
|
|
331
|
+
|
|
320
332
|
function sendContentError(res, statusCode, message) {
|
|
321
333
|
if (!res.headersSent) {
|
|
322
334
|
res.writeHead(statusCode, { 'Content-Type': 'application/json' });
|
|
@@ -605,7 +617,7 @@ async function handleContent(query, req, res) {
|
|
|
605
617
|
const baseHeaders = {
|
|
606
618
|
'Accept-Ranges': 'bytes',
|
|
607
619
|
'Cache-Control': 'no-store',
|
|
608
|
-
'Content-Disposition':
|
|
620
|
+
'Content-Disposition': contentDispositionInline(targetPath),
|
|
609
621
|
'Content-Type': mimeTypeForPath(targetPath),
|
|
610
622
|
};
|
|
611
623
|
const range = parseByteRange(req.headers.range, totalSize);
|