From 738e08ecd52368bdc8c9ee963cb769d8b66e69e2 Mon Sep 17 00:00:00 2001 From: Ayoub-Mabrouk Date: Mon, 24 Nov 2025 19:40:33 +0100 Subject: [PATCH] fix: use correct parameter name in _preferredTypeLegacy function The function was using undefined variable 'extension' instead of the parameter 'ext', causing incorrect behavior when comparing legacy MIME type resolution logic. This bug was introduced in commit 541f9c5 when the function was extracted from populateMaps during the mime-score refactoring. - Changed exports.types[extension] to exports.types[ext] - Fixes incorrect variable reference that would cause undefined behavior --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 9725ddf..3ac8f45 100644 --- a/index.js +++ b/index.js @@ -199,10 +199,10 @@ function _preferredTypeLegacy (ext, type0, type1) { var score1 = type1 ? SOURCE_RANK.indexOf(db[type1].source) : 0 if ( - exports.types[extension] !== 'application/octet-stream' && + exports.types[ext] !== 'application/octet-stream' && (score0 > score1 || (score0 === score1 && - exports.types[extension]?.slice(0, 12) === 'application/')) + exports.types[ext]?.slice(0, 12) === 'application/')) ) { return type0 }