Skip to content

Commit 7c3c63d

Browse files
authored
fix: mime-score logic for mp4 types (#140)
1 parent 1dbaacd commit 7c3c63d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

mimeScore.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ var TYPE_SCORES = {
2525
// prefer font/woff over application/font-woff
2626
font: 2,
2727

28+
// prefer video/mp4 over audio/mp4 over application/mp4
29+
// See https://www.rfc-editor.org/rfc/rfc4337.html#section-2
30+
audio: 2,
31+
video: 3,
32+
2833
default: 0
2934
}
3035

test/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ describe('mimeTypes', function () {
158158
assert.strictEqual(mimeTypes.lookup('.xml'), 'application/xml')
159159
})
160160

161+
it('should return mime type for ".mp4"', function () {
162+
assert.strictEqual(mimeTypes.lookup('.mp4'), 'video/mp4')
163+
})
164+
161165
it('should work without the leading dot', function () {
162166
assert.strictEqual(mimeTypes.lookup('html'), 'text/html')
163167
assert.strictEqual(mimeTypes.lookup('xml'), 'application/xml')

0 commit comments

Comments
 (0)