Skip to content

Commit

Permalink
validators: allow application/octet-stream video as MP4s
Browse files Browse the repository at this point in the history
  • Loading branch information
iparamonau committed Oct 1, 2024
1 parent ddf01dc commit 94748d4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/plugins/validators/async/21_checkContentType.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ export default {
link.error = 'Adobe Flash Player is no longer supported';
}

if (data.type?.toLowerCase() == 'application/octet-stream'
&& link.rel?.indexOf(CONFIG.R.player) > -1
&& link.accept && link.accept instanceof Array
&& link.accept.indexOf('video/*') > -1) {
data.type = CONFIG.T.video_mp4;
if (!link.message) {
link.message = 'Showing application/octet-stream as MP4';
}
}

/** accept-ranges is misconfigured in many cases (especially via CloudFront). Plus, browsers would try and download first range of MP4 file anyway, even if the header isn't set
if (data.type == CONFIG.T.video_mp4 && !/bytes/i.test(data.accept_ranges)) {
link.error = 'MP4s should allow partial download via accept ranges';
Expand Down

0 comments on commit 94748d4

Please sign in to comment.