Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readFile(`./static/${filepath}`, (err, buffer) => {
if (err) {
return Error404Controller.prototype.get.call(this);
}
this.setHeader('Content-Type', Nodal.Mime.lookup(ext) || 'application/octet-stream');
if (this.getHeader('Content-Type').split(';')[0].split('/')[0] === 'video') {
let range = this.params.headers.range;
let len = buffer.byteLength;
if (range) {
range = range
.replace('bytes=', '')
.split('-')
.map(v => parseInt(v))
.filter(v => !isNaN(v))
if (!range.length) {
range = [0];