test: add test for normalizeType fallback when mime lookup fails (#6894)

Add test to verify that utils.normalizeType correctly defaults to
'application/octet-stream' when mime.lookup() returns null/undefined
for unknown file extensions. This covers the fallback behavior on
line 64 of lib/utils.js and ensures proper handling of unrecognized
MIME types.

Co-authored-by: bjohansebas <103585995+bjohansebas@users.noreply.github.com>
This commit is contained in:
Ayoub Mabrouk
2026-02-01 03:53:38 +01:00
committed by GitHub
parent c9ecf7b658
commit 6b7ccfcf12

View File

@@ -35,8 +35,15 @@ describe('utils.normalizeType acceptParams method', () => {
params: {} // No parameters are added since "invalid" has no "="
});
});
});
it('should default to application/octet-stream when mime lookup fails', () => {
const result = utils.normalizeType('unknown-extension-xyz');
assert.deepEqual(result, {
value: 'application/octet-stream',
params: {}
});
});
});
describe('utils.setCharset(type, charset)', function () {
it('should do anything without type', function () {